Example of running this program:
Type A. Nothing on the screen.
Type B. Nothing on the screen.
Type C. Nothing on the screen.
Type e. Everything appears: A,B,C.
In another program, with a simple "switch", no loop, everything is ok.
I am using Visual C++ 6.0.
LE: I just ran this program in CodeBlocks and it works fine.. Anyway can someone tell me what could be the problem in VC++?
In order to display something in the console, system calls are performed. Making these calls has a non-negligible computational cost, independently of the computation of what is displayed.
One common strategy to reduce that cost is to accumulate successive display command in a memory buffer and process them all at once, thus reducing multiple calls to only one.
What I think happened in your case is that the system thought it should keep accumulating and therefore did not display the text.
The flush() command ordered the system to display what was stored into the buffer.