Once again, I'm struggling with writing into my binary file!!
I've got one funtion to enter employee info... Thanks to Prelude I actually got to this funtion, but then I stuck AGAIN!!
The printf() at line 7 is just a test, but this doesn't even work!!Code:void newEmployee(EMP emp, FILE * empfPtr) { int i_temp; char s_temp[MAXLEN]; float f_temp = 0; printf ("Enter new employee ID no.:"); scanf("%d", &i_temp); printf("%d", i_temp); validateID(i_temp, emp, empfPtr); emp.ID = i_temp; fscanf(stdin, "%d", emp.ID); fseek(empfPtr, (emp.ID-1)*sizeof(EMP), SEEK_SET); puts("Enter employee last name:"); scanf("%s", emp.last_name); upperCase(emp.last_name); fputs(emp.last_name, stdin); puts("Enter employee first name:"); scanf("%s", emp.first_name); upperCase(emp.first_name); fputs(emp.first_name, stdin); puts("Enter employee department:"); scanf("%s", s_temp); upperCase(s_temp); validateDept(s_temp); strcpy(emp.dept, s_temp); fputs(emp.dept, stdin); puts("Enter employee salary:"); scanf("%f", &f_temp); validateSalary(f_temp); emp.salary = f_temp; fscanf(stdin, "%d", emp.salary); fwrite(&emp, sizeof(EMP), 1, empfPtr); puts("Next command (0 to print menu): "); return; }



LinkBack URL
About LinkBacks


