Console app hangs until a key is pressed

On Windows,

When you run a console application, it happens that it freezes and it unfreezes just by hitting a key.

That behavior just made me lose about an hour of computing time this morning. Like it is often, the answer seem to be on StackOverflow

I’m trying this.