string bytes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

string bytes

how many bytes string is? i want to import an int to a string. is that possible?

26th Nov 2018, 12:55 PM
Abolhasan Ashori
Abolhasan Ashori - avatar
4 Answers
+ 6
"size of a String includes number of characters you enter and a null character" Wrong! In C++'s basic string class, null terminator won't be appended to the end of the sequence. string s = "Hi"; cout << "Length of s: " << s.length(); // 2 ~~~~~~~~~ "i think it is not possible to convert int to string but [...]" What are you talking about?! 8D std::to_string Converts a numeric value to std::string [See example in the below link] ____ https://en.cppreference.com/w/cpp/string/basic_string/to_string
26th Nov 2018, 1:14 PM
Babak
Babak - avatar
+ 6
i think it is not possible to convert int to string but ya we can import int to char
26th Nov 2018, 12:59 PM
Mehak Jain
+ 3
The question is about C++ and `string`! 8D
26th Nov 2018, 1:17 PM
Babak
Babak - avatar
+ 2
not even like this? int a =1; string = a;
26th Nov 2018, 1:03 PM
Abolhasan Ashori
Abolhasan Ashori - avatar