I am learning file handling in C.I have this code but it is not accepting string as an input to write it to a file.Any help will be appreciated.
  #include<stdio.h>
#include<string.h>
#include <stdlib.h>
    int main(void)
    {
        FILE * fp1;
        fp1 = fopen("abc.txt","a+");
        if(fp1==NULL)
        {printf("An error occurred");
        }
        printf("Delete file?\n");
        int a,c;
        char name [20];
        int flag=1;
        int ch=1;
        while(flag!=0)
            {
                printf("Enter id input \n");
                scanf("%d",&a);
                fprintf(fp1,"\n%d\t",a);
                printf("Enter Name");
                gets(name);
                fputs(name, fp1);
                printf("Enter No \n");
        scanf("%d",&c);
        fprintf(fp1,"\t%d\t",c);
        printf("Write more then press 0 else 1");
        scanf("%d",&ch);
        if(ch==1)
            {
                flag=0;
            }
        }
        fclose(fp1);
    }
On running this code the code does not take an input after Enter Name and directly skips to Enter No.I want the output to be in a tabular form.
 
     
     
     
    