Simple string operation (note points)

String Processing

Simple string operation (note points)

1, string variable length character string constant to store at least one more than, because there is a sign of the end for the \ 0.
For example, a [10] = "ABCDEFGHIJ "; is wrong, it should be a [11] or more characters in length.
2, can not be a string variable to another string variable. For example, a [1] = a [2 ]; or a [2] = a [1 ] is wrong.
3, variable length arrays may be defined, for example, char a []; which is assigned to a string constant.
Example:
#include <stdio.h>
int main () {
char A [2] = "0";
char B [. 3] = "0";
char C [] = "0";
int m;
Scanf ( "% S ", A);
Scanf ("% S ", B);
Scanf ("% D ", & m);
the printf ("% S \ n-", A);
the printf ("% S \ n-", B);
the printf ( "% S \ n-", C);
the printf ( "% D \ n-", m);
}
the above example of the input string is output. The figure below shows the experimental results.Here Insert Picture Description

Guess you like

Origin blog.csdn.net/m0_45128748/article/details/91488843