1. There is no string type in C language, and there is no string variable. Strings are implemented as character arrays.
2. The array name is the address of the first element of the array.
3. scanf("",x); The second parameter should be the address, but for character arrays, & can be used or not.
Specific code:
#include <stdio.h> int main() { char a[26],b[10]; scanf("%s%s", a,&b); printf("a=%s,b=%s", a, b); system("pause"); return 0; }
Result:
输入: abc 123 输出:a=abc , b=123
Recommended tutorial: c language tutorial
The above is the detailed content of How to use scanf to input string in C language. For more information, please follow other related articles on the PHP Chinese website!