马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
#include <stdio.h><BR>#include <stdlib.h><BR>#define MAX 40<BR>int main (void)<BR>{<BR> FILE *fp;<BR> char words[MAX];<BR><BR> if((fp = fopen("words","a+")) == NULL)<BR> {<BR> fprintf(stdout,"Can,t open \"words\"file.\n");<BR> exit(1);<BR> }<BR> puts("Enter words to add to the file:press the Enter");<BR> puts("key at the beginning of a line to terminate.");<BR> while(gets(words) != NULL && words[0] != '\0')<BR> <FONT color=#ff0000> fprintf(fp,"%s ",words);</FONT> <BR> puts("File contents: ");<BR> rewind(fp);<BR> while(fscanf(fp,"%s",words) == 1)<BR> puts(words);<BR> getch();<BR> if(fclose(fp) != 0)<BR> fprintf(stderr,"Error closing file\n");<BR> return 0;<BR>}<BR>上面程序中,紅字部分起到什麼作用? |