int main(void)
{
char str[80];
FILE *fp;
if((fp=fopen ("junk","w"))==NULL) {
printf("cannot open file.\n");
exit(1);
}
do {
printf("Enter a string (cr to quit):\n");
gets(str);
strcat(str,"\n"); /* add a newline */
fputs(str,fp);
} while(*str!='\n');
return 0;
}