Here's the issue: I'm making a Snake version on Code::Blocks (C programming) for a school project, and I got stuck at trying to exeute simultaneous actions in a single code. Long story short, I'd like to play a song ("many sequential Beeps") while the user chooses his option on a give menu. Problem is the program has to wait until the song is finished before it can scanf the given variable, just like in the code below.
int main()
{
song();
scanf(" %c",&option);
printf("%c", option);
return 0;
}
Any suggestion would be more than welcome. Thanks.
I recommend you use different Threads for both process you want to have simultaneously.
Take a look at this question regarding threads and forks.
Hope this helps :)
EDIT:
As noted by @Barmar take a closer look at the first link regarding threads (more useful for your question), where you will need to run one for each task you want simultaneously (that is beep and user input).
Forks would be useful if, for example, you need to duplicate your game process to have several instances of them. Given the question you asked, threads are the way to go.