Result of gcc complie does't follow the correct sequence of "printf"
Hello, everyone. I found a problem about the wrong sequence of the "printf" when using gcc compiler in Msys2. There are no prints when I call the "printf" function in the "menu" block. In Msys2, using command " ./a.exe ", there are no prints at first, when I input the digits, but the prints appears after I quit the program. In Window10, double click the a.exe, it prints the message, prints again when I input the digits again. It alway print the messages until I quit the program. (correct running) In Debian11.3, complie with the same code, run the result "./a.out", running is correct too, just like in Windows10.
The c codes are from "C Primer Plus (6th Edition)"-chapter 9: Listing 9.9 usehotel.c Listing 9.10 hotel.c Listing 9.11 hotel.h
Running in Msys2(wrong running):

Running in Debian11 3(correct running):

Running in Windows10(correct running):

Something wrong with Msys2 gcc? How to fix it? hotel.zip
Aside from mintty, perhaps you might require a fflush(stdout); after your printfs.
Afaik, mintty (the terminal emulator msys2 uses) handles stdout, stdin, and stderr in a bit special way as they are actually just piped "files" or something, so that might be the reason why?
This might be a MinTTY quirk. Try running the program using WinPTY.
I confirm this bug on Windows 8.1
Will the MinTTY fix this problem?
This might be a MinTTY quirk. Try running the program using WinPTY.
Will the MinTTY fix this problem?
Maybe try adding fflush(stdout); every time before calling scanf to tell the terminal that the output buffer should be flushed. Otherwise, the behavior of your example is implementation dependent (iiuc).