我想写一个用户可以输入评论的子程序.我使用scanf("%s", X)并让他们输入注释,但它只能将字存储在字符串中的空格键之前.
如何将整个句子存储到字符串或文件中来解决此问题?
我的代码如下:
FILE *fp;
char comment[100];
fp=fopen("comment.txt","a");
printf("You can input your comment to our system or give opinion to the musics :\n");
scanf("%s",comment);
fputs(comment,fp);
Run Code Online (Sandbox Code Playgroud)