0

i have written the code,but i am getting an empty line in the starting so,can you help to sort out this problem so i won't get a empty line in the starting please explain briefly

#include<stdio.h>
int main()
{
   int n,x=0;
   FILE *fp;
   char line[80];
   fp = fopen("file.txt","W");
   printf("enter the number of lines to be entered:");
   scanf("%d",&n);
   while(x<=n)
   {
       fgets(line,100,stdin);
       fputs(line,fp);
       x++;
   }
   fclose(fp);
}
geek
  • 1
  • 1

0 Answers0