I have a minor problem i want to check for error that the user might enter. For example if i ask for a number and the used enters a letter it would prompt saying that the entered crap here's my code:
Code:
int emp_details()
{
FILE *fp;
fp=fopen("EMP_DETAILS.txt", "a+");
char emp_name[100];
char address[100];
char email[100];
int tel;
int age;
int trn;
int v_id;
printf("\n\t\t\t****Employee Information Screen****\n\n\n");
printf("Enter Employee's Name: ");
scanf(" %[^\n]s ",&emp_name);
printf("\n----------------------------------------------------\n");
printf("\nPlease Enter Employee's Address: ");
scanf(" %[^\n]s ",&address);
printf("\n----------------------------------------------------\n");
printf("\nPlease Enter Employee's Email: ");
scanf("%s",&email);
printf("\n----------------------------------------------------\n");
printf("\nPlease Enter Employee's Telephone #: ");
scanf("%d",&tel);
printf("\n----------------------------------------------------\n");
printf("\nPlease Enter Emplyee's Age: ");
scanf("%d",&age);
printf("\n----------------------------------------------------\n");
printf("\nPlease Enter Employee's TRN#: ");
scanf("%d",&trn);
fprintf(fp,"----------------------------------------------------\n");
fprintf(fp,"Employee Information Generated on: %s", __DATE__);
fprintf(fp,"\n----------------------------------------------------\n");
fprintf(fp, "Employee's Name Is: %s\n", emp_name);
fprintf(fp,"\nEmployee's Address: %s\n", address);
fprintf(fp,"\nEmployee's Email: %s\n",email);
fprintf(fp,"\nEmployee's Telephone#: %d\n",tel);
fprintf(fp,"\nEmployee's Age: %d\n",age);
fprintf(fp,"\nEmployee's TRN#: %d\n",trn);
fprintf(fp,"\n----------------------------------------------------\n\n");
fclose(fp);
system("CLS");
printf("\n\n\tInformation Processed... Press Any Key To Return To Main Menu");
getch();
system( "CLS");
first_menu();
}