#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char buf[100]={0};
printf("请输入字符串:");
scanf("%s",buf);
printf("buf=%s\n",buf);
char tmp[100]={0};
printf("请输入字符串:");
scanf("%s",tmp);
printf("tmp=%s\n",tmp);
//这里如果你输入的超过了10个,不同编译器不同
//当你超过10个有些会报错,有些编译器不会报错
char str[10]={0};
printf("请输入字符串:");
scanf("%s",str);
printf("str=%s\n",str);
printf("\n");
system("pause");
return 0;
}
这里不建议使用scanf作输入函数,因为他不安全,他不会对输入的进行检查
网友评论