Difference between character array and string...???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Difference between character array and string...????

8th Jul 2017, 1:20 AM
Hassam Usmani
Hassam Usmani - avatar
2 Answers
+ 11
A character array is just a character array, while a string is a class which contains a character array, and has built-in methods to help you manage that character array. You may choose to allocate memory for a character array on the stack or the heap, while strings are automatically managed for you. https://stackoverflow.com/questions/1287306/difference-between-string-and-char-types-in-c
8th Jul 2017, 1:49 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
string is a C++ generic type of the <string> header (with a variable size) the array of chars with ending '\0' is the old C 'string' type (with an specific max size)
8th Jul 2017, 1:43 AM
Andrés04_ve
Andrés04_ve - avatar