This Code Isn't Working ProperlyCode:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
system("cls");
struct contact
{
double tel, mob, pin, age;
char add[300], fname[10], mname[10], lname[10], email[30];
}
c;
FILE *fp;
int input_choice, sizeofc = sizeof(c), buffwer = 512;
printf("Contact Manager app.");
printf("\nAdd Contacts. ");
//More options to be added.
printf("Your Choice: ");
scanf("%d", &input_choice);
switch(input_choice)
{
case 1:
fp = fopen("contact.txt","wb");
//Taking input.
printf("Enter Firstname: "); //firstname
gets(c.fname);
printf("Enter Middlename: "); //middlename
gets(c.mname);
printf("Enter Lastname: "); //lastname
gets(c.lname);
printf("Enter Age: "); //age
scanf("%f", c.age);
printf("Enter Address: "); //address
gets(c.add);
printf("Enter Telephone no.:"); //telephone
scanf("%f", c.tel);
printf("Enter Mobile no.: "); //mobile
scanf("%f", c.mob);
printf("Enter Pincode: "); //pincode
scanf("%f", c.pin);
printf("Enter Email ID: "); //Email ID
gets(c.email);
//Printing in the file.
fputs(fp, c.fname);
fprintf(fp, "\n");
fputs(fp, c.mname);
fprintf(fp, "\n");
fputs(fp, c.lname);
fprintf(fp, "\n");
fprintf(fp, "%f", c.age);
fprintf(fp, "\n");
fputs(fp, c.add);
fprintf(fp, "\n");
fprintf(fp, "%f", c.tel);
fprintf(fp, "\n");
fprintf(fp, "%f", c.mob);
fprintf(fp, "\n");
fprintf(fp, "%f", c.pin);
fprintf(fp, "\n");
fprintf(fp, "%f", c.email);
//fwrite(512, sizeofc, 1, fp);
fflush(fp);
fclose(fp);
break;
}
system("pause");
return 0;
}