Monkey_C:
when I get into that function, it prints "enter employee ID No", and when I enter a number I doesn't do the rest => asking for the last name, first name, etc. It just creates a blanck newline.
I actually changed this part since I posted it: (here's the whole function)
Code:
void newEmployee(FILE * empfPtr) {
int i_temp = 0;
char s_temp[MAXLEN];
float f_temp = 0;
EMP emp;
printf("Enter an employee ID No.: ");
scanf("%d", &i_temp);
printf("%d", i_temp);
validateID (i_temp, empfPtr);
emp.ID = i_temp;
fseek(empfPtr, (emp.ID-1)*sizeof(EMP), SEEK_SET);
fwrite(&emp.ID, sizeof(int), 1, empfPtr);
puts("Enter employee last name:");
scanf("%s", emp.last_name);
upperCase(emp.last_name);
fwrite(emp.last_name, sizeof(emp.last_name), 1, empfPtr);
puts("Enter employee first name:");
scanf("%s", emp.first_name);
upperCase(emp.first_name);
fwrite(emp.first_name, sizeof(emp.first_name), 1, empfPtr);
puts("Enter employee department:");
scanf("%s", s_temp);
upperCase(s_temp);
validateDept(s_temp);
strcpy(emp.dept, s_temp);
fwrite(emp.dept, sizeof(emp.dept), 1, empfPtr);
puts("Enter employee salary:");
scanf("%f", &f_temp);
validateSalary(f_temp);
emp.salary = f_temp;
fwrite(&emp.salary, sizeof(emp.salary), 1, empfPtr);
puts("Next command (0 to print menu): ");
return;
}
Quzah:
I open the file with wb (that updates, right?)