文本写入
程序代码:#include<stdio.h>
#include<stdlib.h>
#define MAX 40
int main()
{
FILE *fp;
char words[MAX];
if((fp=fopen("55.txt","a+"))==NULL)
{
fprintf(stdout,"can't open \"xx.txt\"file.\n");
exit(1);
}
puts("Enter words to add to the file:press the Enter");
puts("Key at the beginning of a line to terminate.");
while(gets(words)!=NULL&&words[0]!='\0')
fprintf(fp,"s",words);
puts("file contents: ");
rewind(fp);
while(fscanf(fp,"%s",words)==1)
puts(words);
if(fclose(fp)!=0)
fprintf(stderr,"Don't close\n");
return 0;
}
我照着书上打了,就是写入文本的单词,不管怎么样他都是ss,为什么他不会是单词









