The C language does not have the same string type as in Java, so in the C language, by using a character array to hold the string, in order to distinguish it from the normal character array, we need to add the trailing end of the string
An end flag: ' \ s ', so, for example, a string: "Bht", the character array that holds the string is 4 long.
Initialization of the string:
1 Chara[4]={'b','b','T',' /'};2 3 Charb[4];4b[0]='b';5b[1]='h'.......6 7 Charc[]="BHT";
If you use the 7th line of code, the length of the character array is not 3, but 4, the system will automatically add the end of the "\" This flag!
About the difference between puts () and gets () two functions and the printf () and scanf () functions
In Xcode, if you use the puts () and the Get () function, the compiler will prompt the two functions to be unsafe. For what? The following is a description of get and puts, the two separate expressions
Receives a string and outputs a string that can receive spaces and tab keys, while printf and scanf are not allowed . But puts and get are not as flexible as printf and scanf, which can be output one at a time .
or receive multiple strings.
The following procedures are safe:
Char a[]="bht"; Char b[]={'i','m'}; Puts (b);
If, at the time of defining the string (b), after forgetting to knock ' s, the output of the IMBHT analysis can be explained as follows:
In-memory scenario:
Since both the puts and the gets are read to ' \ ', the subsequent array A will also be printed to the console. There's a memory allocation problem here.
C Language Learning---day1 (array of strings, pointers)