求大佬们帮忙看看这段代码

weixin_45906870 2020-05-11 08:26:34
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 41

int main()
{
FILE *fp;
char words[MAX];

if ((fp = fopen("wordy", "a+")) == NULL)
{
fprintf(stdout, "Can't open \"wordy\" file.\n");
exit(EXIT_FAILURE);
}

puts("Enter words to add to the file; press the #"); //这里的#是什么意思?有何作用?
puts("key at the beginning of a line to terminate.");
while ((fscanf(stdin, "%40s", words) == 1) && (words[0] != '#')) //这里的#是什么意思?有何作用?
fprintf(fp, "%s\n", words);

puts("File contents:");
rewind(fp);
while (fscanf(fp, "%s", words) == 1)
puts(words);
puts("Done!");
if (fclose(fp) != 0)
fprintf(stderr, "Error closing file\n");

return 0;
}
...全文
66 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_45906870 2020-05-11
  • 打赏
  • 举报
回复
十分感谢,我还以为是其他的意思
棉猴 2020-05-11
  • 打赏
  • 举报
回复
这段英文的意思就是“请输入写入到文件中的单词,在每行的起始位置处按下#按键来结束输入。” 从下面的输入可以看到,当输入结束时,按下#键即可

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧