69,336
社区成员
发帖
与我相关
我的任务
分享
int scanf(const char *format, ...);
The scanf() family of functions scans input according to format as
described below. This format may contain conversion specifications;
the results from such conversions, if any, are stored in the locations
pointed to by the pointer arguments that follow format. Each pointer
argument must be of a type that is appropriate for the value returned
by the corresponding conversion specification.
If the number of conversion specifications in format exceeds the number
of pointer arguments, the results are undefined. If the number of
pointer arguments exceeds the number of conversion specifications, then
the excess pointer arguments are evaluated, but are otherwise ignored.
The scanf() function reads input from the standard input stream stdin,
fscanf() reads input from the stream pointer stream, and sscanf() reads
its input from the character string pointed to by str.
scanf("%s", a);
去掉a前的&;因为a是字符数组,数组名本身就是地址,因此不需要加&;