I just finish writing LAB2 with no errors when compiling
but once i run it, I get "segmentation fault".
I don't know what is wrong,
Can anyone tell me what it means and how I can fix it?
Your program is attempting to reference memory
which doesn't belong to it.
You probably have an array index which is "out-of-bounds".
Use your debugger. If you don't have a debugger or know how to use it,
you can insert statements to print diagnostic messages
fprintf(stderr, "Got to this point in the program!\n"); fflush(stderr);
Put the first one smack dab in the middle of your code.
If you get the "segmentation fault" before the diagnostic message
you know that the error is before the print statement and
the error is after the print statement
if you get the diagnostic message before the "segmentation fault".
A short binary search usually locates the error quickly.