You could use the _beginthread function, it's used like this:
_beginthread(manageKeys,0,NULL);
The manageKeys function would have to look like this:
void manageKeys(void *p);
When calling the _beginthread function, it creates a new thread and executes the manageKeys function in it. Your program should look something like:
Code:
void manageKeys(void *p);
int dir[1000]; // this is the dir array you used in your sample code, don't know if it's the right type and stuff, doesn't matter too much
int main() {
// initial code
_beginthread(manageKeys,0,NULL);
while(1) {
// Move the snake here
}
return 0;
}
void manageKeys(void *p) {
while(1)
getkey();
_endthread();
}