赣州中级人民法院招聘:请问C程序里 把键盘接收字符串输出时 字符串中空格 用什么来实现

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 00:24:45
include <stdio.h>
main()
{
char ary[100];
char ch='y';
for (;ch == 'y';)
{
printf("please select function:input(1),statistics(2):");
FILE *fp;
fp =fopen("statistics.txt","a");
if (getchar() == '1')
{
printf("please input some characters:\n");
scanf("%s",ary);
}
getchar();
fprintf(fp,"%s",ary);
fclose(fp);
printf("continue? <yes or not>:");
ch=getchar();
}

}
上面程序
我如果想把键盘接受输入的中间带有 "空格"的字符串全部保存到statistics.txt这个文件里 应该怎么写
是不是我用数组来接收输入不合理