I have seen tutorials that are using an array of characters in order to demonstrate something with a string object. For example thees tutorials:
http://www.cplusplus.com/reference/string/string/copy/
http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/
I HAVE seen tutorials that are not using a char array in order to demonstrate something. At school, the teacher also doesn’t use any arrays. For me, using an array is a bit confusing at first when I’m reading the tutorial (knowing that I’m still a beginner at C++).
I’m just curious to know why are there tutorials that use a char array in order to show one or more of the things that string objects can do.
Storing strings in arrays of characters was the original way to represent a string in the C language. In C, a string is an array of type char. The size of the array is the number of characters, + 1. The +1 is because every string in C must end with a character value of 0. This the NULL terminator or just the terminator.
C-style strings are legal in C++ because C++ is intended to be backwards compatible with C. Also, many library and existing code bases depend on C-style string.
Here is a tutorial on C-style strings. http://www.cprogramming.com/tutorial/c/lesson9.html
FYI: To convert a C++ String to a C-style string, call the method c_str().