我想编写一个子程序,用户可以在其中输入他们的评论。我使用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);