lundi 3 août 2020

how do I tell the string to read the 0 and not abort?

I have a string with numbers, including 0. Unfortunately the string recognize the number 0 as \0 and finishes reading in. Is there a way to interpret the 0 as 0 and read it? My program is written in C++.

char arrayOfChars[] = { 23, 4, 0, 234, 8}
string test(buf);

For this case the string 'test' will contain 23 and 4. But for my case it should contain 23, 4, 0, 234 and 8.

These ways are not an option for me:

string test "abc\0\0def"s;            
string test R"abc\0\0def";

Aucun commentaire:

Enregistrer un commentaire