化合价有什么用:请问C程序里 把键盘接收字符串输出时 字符串中空格 用什么来实现

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 16:55:26
#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();
}

}
上面程序 我如果想保存中间带有空格的数组怎么写
是不是我用数组来接收输入不合理
请厉害的大哥大姐帮忙

要接收 空格就用 gets()