string C++ and C-string

What is a string in C++ and what is the difference with C-string;
What is the use of string tables in c++;
The reference section of this site has a section on C++ strings. I recommend taking a look at that.
string in c++ is a class/object with methods and internal memory management and more.

c-strings are arrays of type char that end in a zero character; there are a number of C functions you can call on them to get length, concat, substring, etc. but these are not tied to the array, its "procedural" programming style not "object" style.

c-strings can have buffer overflows and pointer malfunctions. C++ string prevents most of these so long as you only use methods for the object.

You should not use c-strings in new c++ code without a good reason. There are still libraries and tools that use c-strings or return them from function calls; you may need to do a little c-string hands-on for those.
Last edited on
Topic archived. No new replies allowed.