#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
  {
    FILE *fp ;
    char str[80];
    clrscr();
    if(!(fp = fopen("test","w+"))) {
       printf("cannot open file.") ;
       getch();
       exit(1);
    }
    printf("enter strings(Enter to quit):\n");
    while (1)  {
       gets(str);
       if(!str[0])
   break ;
       strcat(str,"\n");
       fputs(str, fp);
    }
    printf("the content of file is:\n\n");
      rewind(fp);
      fgets(str, 79, fp);
      while (!feof(fp)) {
  printf("%s", str);
  fgets(str, 79, fp) ;
      }
      fclose(fp);
      getch();
      return 0;
}