Cygwin64 bit
Command to compile:
gcc hello.c -o hello -ansi -pedantic-errors
Command to run
./hello
hello.c
#include<stdio.h>
int main() {
/*setbuf(stdout, 0); I KNOW THIS WILL WORK IF ADDED, it is a solution, but I want to know why line break itself is not working*/
printf("hello world!\n");
printf("hello world again!\r\n");
/*fflush(stdout); without fflush, the above strings are not showing*/
while(1)
{
}
}
Questions:
I don't want a fflush after every printf to let the terminal show the string in time, then how?
ANSWER: setbuf(stdout, 0);
Why is "\n" or "\r\n" not working in my case considering lots of posts pointed out a line break will fix the problem?
Is it true that cygwin's terminal behaves differently than normal Linux's terminal? Since I don't have linux installed, anyone give a test for me?
Or let me ask a more general question: On which kinds of terminals, the sentence "a new line will force flush" is true?
Thanks