If someone asks me the difference between the Char array and the string, I can't answer. Past learning seems to be more sloppy, the foundation is very unresolved. . . Khan ~~ This time, "C Primer Plus", read the fourth chapter, has a relatively clear concept of this issue. C or class C language, strings are Null Character. In the specific implementation, writing "/ 0". Its ASCII code value is 0, and the end is the key to the end of the string and the char array at the end of "/ 0". Here is a small example I use to write with CinClude "stdio.h" main () {Int i; char Array1 [5] = {'b', 'a', 'a', 'i', 'a' }; char Array2 [5] = {'b', 'a', '/ 0', 'i', 'a'}; char string1 [] = "c program"; char string2 [] = "c / 0 Program "; for (i = 0; i <= 4; i ) {printf ("% c ", array1 [i]);
} Printf ("/ n"); for (i = 0; i <= 4; i ) {printf ("% c", array2 [i]);} printf ("/ n"); printf ("% s / N ", string1); Printf ("% s ", string2); getCh ();}
Output is: Baaia Ba IA C Program C
Obviously, in the string, once the compiler captures "/ 0", it is considered that the string is here, stop the operation. In the array, "/ 0" is only treated as an empty character. In some procedures, you should pay attention to the difference between the two.