hello,i'm having troubles with gets() function @ void add_employee()
nothing works i can't accept data, please help me.
Code:
#include <stdio.h>
#include <string.h>
struct employee
{
int employee_ID;
char employee_name[50];
int employee_age;
char employee_DateOfBirth[10];
char employee_address[70];
char employee_TelNo[20];
float emplayee_salary;
}employee_array[50]; // structure variable
void print_line(); // function prototypes
void add_employee();
void edit_employee();
void delete_employee();
void search_employee();
void print_employee();
int main()
{
int option;
//clrscr();
print_line();
printf("This program provides the functionality to \n");
printf("interface with an employee information system.");
print_line();
printf("Enter [1] - to enter employee profile \n");
printf("Enter [2] - to edit employee \n");
printf("Enter [3] - to delete employee \n");
printf("Enter [4] - to search for employee \n");
printf("Enter [5] - to print employee information \n");
printf("Enter [0] - to exit\n\n");
printf("Please select an option:\t");
scanf("%d",&option);
getchar();
while(option != 0)
{
switch(option)
{
case 1: add_employee();
break;
case 2: edit_employee();
break;
case 3: delete_employee();
break;
case 4: search_employee();
break;
case 5: print_employee();
break;
default:
printf("\n\nIncorrect Entry!,Please press enter and Try again!\n\n");
getch();
}
printf("\n\n");
print_line();
printf("This program provides the functionality to \n");
printf("interface with an employee information system.");
print_line();
printf("Enter [ 1 ] - to enter employee profile \n");
printf("Enter [ 2 ] - to edit employee \n");
printf("Enter [ 3 ] - to delete employee \n");
printf("Enter [ 4 ] - to search for employee \n");
printf("Enter [ 5 ] - to print employee information \n");
printf("Enter [ 0 ] - to exit\n\n");
printf("Please select an option:\t");
scanf("%d",&option);
}
getch();
}
void print_line()
{
int i;
printf("\n");
for(i=0;i<48;i++)
{
printf("-");
}
printf("\n");
}
void add_employee() // decleration of add employee function
{
int i;
printf("\nEnter employee ID or 0 to exit:\t");
scanf("%d",&employee_array[i].employee_ID);
while(employee_array[i].employee_ID !=0){
printf("Enter emplayee name:\t");
gets(employee_array[i].employee_name);
printf("\nEnter employee age");
scanf("%d",&employee_array[i].employee_age);
printf("\nEnter employee Date-Of-Birth:\t");
gets(employee_array[i].employee_DateOfBirth);
printf("\nEnter employee address:\t");
gets(employee_array[i].employee_address);
printf("\nEnter employee telephone number");
gets(employee_array[i].employee_TelNo);
printf("\nEnter employee salary");
scanf("$%f",&employee_array[i].emplayee_salary);
printf("\n\nEnter employee ID or 0 to exit:\t");
scanf("%d",&employee_array[i].employee_ID);
fflush(stdin);
i++;
}
}
void edit_employee()
{
}
void delete_employee()
{
}
void search_employee()
{
}
void print_employee()
{
}