Hey there!
I've started to learn C and i'd like to create a little Game in the Console.
The Goal is to have a Frontbuffer and a Backbuffer which can be swapped, so i can build the hole Screen at once instead of messing with a bunch of fprintf or similar calls.
I kinda figured out how to do the swapping of Buffers (although there may be problems i'm not aware of), but what's giving me a headache is receiving Input!
I've read the Microsoft Documentation for a bunch of stuff, i've searched on StackOverflow, i tried asking ChatGPT, but i am seriously stuck. Depending on what i try, there's 3 different outcomes, being
- the Program crashes silently when reaching the relevant portion of the Code
- the Program continues to run, but the assertion fails due to an Invalid Handle
- the Program runs up to that point and allows for Input, but terminates after a single keypress
what i actually want to happen is what functions like fgets or fscanf provide (which i also tried, both, with the same amount of success), basically blocking the Thread, allowing the User to enter some text and continue after Enter is pressed.
Code: https://pastebin.com/HnMHaWs1
The Input 'Logic' is between Lines 60 and 70, any insights are highly appreciated (and feel free to roast my code for everything that's wrong), i've been literally trying to get this working for 2 hours 🙂
(Current Behaviour:
- first Buffer shows
- sleeps 1 second
- second Buffer shows
- sleeps 1 second
- Program either crashes silently or assertion fails.
'Expected' Behaviour:
- first Buffer shows
- sleeps 1 second
- second Buffer shows
- sleeps 1 second
- User can enter Input
- Program terminates on Enter)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.