I have this program that won't print everything I tell it to. It's very strange.
In the middle of the program I wrote:
1 2 3
printf("MADE IT HERE!");
printf("Sat up LUID's.\n");
printf("MADE IT HERE!");
That is literally 3 lines of it in a row.
It prints the first "MADE IT HERE!" then prints "Sat up LUID's" so my output looks like: MADE IT HERE!Sat up LUID's.
and then the code seems to completely go past the next "MADE IT HERE!" until it reaches the error I'm having.
I just get a Segmentation fault sometime after "Sat up LUID's." but I don't know when.
That's why I'm trying to narrow it down in my code with the "MADE IT HERE!"s.
Edit: When I debug with gdb, I can step past the "Sat up LUID's." and the debugger will actually see the next line where I try to output "MADE IT HERE!". When I hit step, though, it just shows the next line after that without showing the output.
output is buffered. Your data was probably being printed, it just wasn't being flushed. If it's not flushed, it won't be visible on screen.
Flushing occurs automatically on new lines. So...
1 2 3 4 5
printf("MADE IT HERE!");
printf("Sat up LUID's.\n"); // <- this newline would cause all output to be flushed
printf("MADE IT HERE!"); // <- whereas this would just sit in the buffer and not be visible
// until flushed. Since there's no newline
puts might output and flush implicitly, whereas printf might not.
Possible solutions are to add a newline printf("MADE IT HERE!\n");
or explicitly flush: fflush(stdout); *
* Note I'm not sure if 'stdout' is the correct name for it. Maybe it's STDOUT? try it and see.