Create File With Scanf


            #include<stdio.h>
            main()
            {
                FILE *fp;
                int id, salary;
                char name[100];  /* Corrected the type for name to char[] */
                fp = fopen("xyz.txt", "w+");
                clrscr();
        
                if(fp == NULL)
                {
                    printf("File does Not Exist");
                    return;
                }
                
                printf("\n Enter the ID. : ");
                scanf("%d", &id);
        
                fprintf(fp, "\n id=%d", id);
                
                printf("\n Enter the Name : ");
                scanf("%s", name);
                fprintf(fp, "\n Name=%s", name);
        
                printf("\n Enter the Salary : ");
                scanf("%d", &salary);
                
                fprintf(fp, "\n Salary=%d", salary);
                fclose(fp);
            }
        

Output: