主题:[讨论]请问高手如何结束这个程序的读取
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main (void)
{
FILE* spoutfile;
char strng[81];
if(!(spoutfile=fopen("an.txt","w")))
{
printf("\a could not open file");
exit(100);
}
while(fgets(strng,sizeof(strng),stdin))
{
fputs(" ",spoutfile);
fputs(" ",spoutfile);
fputs(strng,spoutfile);
if(strng[strlen(strng)-1]!='\n')
fputs("\n",spoutfile);
}
fclose(spoutfile);
return 0;
}
#include<stdlib.h>
#include<string.h>
int main (void)
{
FILE* spoutfile;
char strng[81];
if(!(spoutfile=fopen("an.txt","w")))
{
printf("\a could not open file");
exit(100);
}
while(fgets(strng,sizeof(strng),stdin))
{
fputs(" ",spoutfile);
fputs(" ",spoutfile);
fputs(strng,spoutfile);
if(strng[strlen(strng)-1]!='\n')
fputs("\n",spoutfile);
}
fclose(spoutfile);
return 0;
}