I have an ncurses program that looks like this:
1. int c =0;
2. initscr();
3. timeout(-1);
4. printw("Enter a character");
5. getch();
6. printw("\nOkay\n");
7. c = 5;
I would expect that the output getch(), as well as the next one, printw()should happen (and be visible on the screen) before c is changed to 5. However, this does not seem to happen (using qemu-kvm and a breakthrough at this point to check ) Is there a reason why this can happen, or is there any way to guarantee that the output will be visible on the screen before executing the next statement? fflush (stdout) guarantees that?
The OS is virtualized, gentoo starts using qemu-kvm. The screen is in console mode (X not initialized).
source