Quote Originally Posted by anduril462 View Post
Does employee.dat exist? You need to check the return value of fopen before trying to do anything with file. The program crashed for me, then when I created an empty employee.dat, it worked without crashing.

I used a debugger to solve this, and it took me about 1 minute. You should also learn to use a debugger, as it is an invaluable tool and will help you track down these issues yourself. It allows you to step through the code line by line and see exactly what the value of each variable is and often takes you to the exact line that causes your crash.
I created a blank employee.dat file and this is what the compiler gave me

"lab7.c", line 4: warning: invalid white space character in directive
"lab7.c", line 38: warning: implicit function declaration: strcpy
"lab7.c", line 82: warning: newline not last character in file
luna:~>a.out
0 ÿ¿ót
0 ÿ¿ót