i have made a small opengl program using the d programming language. what i am trying to do is to allow the program to read input from the console. i have tried to use readf(), getc() and some other functions. but my problem is i don’t want the program to pause while looking for input.
i have tried to search around for a solution but could not find any. so if anyone know how to check if something actually have been written in the console and if so read that. or if there exists any function that reads from console, but will be ignored if nothing gets written.
i mainly would like to know how to do this in d but a solution for c++ could be useful too.
You need to use a separate thread. Something like this is one way to do it in D:
This spawns a separate thread which does the console input waiting while your main thread can do other work.