This is the most basic tip I can give all students that have to start working in C. Use: fflush(stdout);

If your program crashes, the output stream just gets dumped instead of well.. outputted. So then, even if you use printf statements to figure out where your program crashed, the last print statement you see might not be the last one that was executed. BUT, if you put fflush(stdout) after your debug prints, then they will be immediately shown, so you know what’s going on. That simple!