-
Problem
I am writing a program that among other things prints out an array of characters. In order for it to work, I need to print a new line to the console. Without this, it freezes. Can anyone suggest why this is happening?
Code:
for(i = 5; i >= 0; i--){
printf("%c", test[i]);
}
printf("\n");
If I comment out the "printf("\n");" statement, it freezes before it gets to this part of the code. My program also makes use of threads. Any help would be much appreciated.
-
On many systems, the console is line-buffered, that it the whole line isn't printed until you move to the next one, with "\n".
EDIT: Mind you, printf outputs to "stdout" which is the standard output stream, and is buffered. On the other hand "stderr", standard error stream, isn't buffered! Just so you know. You could use "fprintf(stderr, ...)".
-
Thank you very much, sorted.