- Edited
Okay so here's the problem. I'm trying some new (to me) concepts in multithreaded programming in c++, and I got to this freaking problem. I'm using process.h, and the _beginthread() function to call my functions. It works like a charm, and i've learned to use the critical section to suit my needs till now. Problem is, I don't know how to pass functions that take parameters to the _beginthread() function... anyways this is what i'm trying to do. its not nearly done, just a proof of concept, so all i want is to know how to call the second function that takes a char parameter, if it can be done.
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <conio.h>
#include <process.h>
using namespace std;
HANDLE hOut;
COORD Position;
char keys;
void choice (void *);
void verk (void *);
int main()
{
getch();
_beginthread(choice,
0,
NULL);
_beginthread(verk,
0,
NULL);
return 0;
}
void verk (char key, void *P){
switch(key){
case 'd':
Position.X++;
break;
case 'a':
Position.X--;
break;
case 'w':
Position.Y++;
break;
case 's':
Position.Y--;
break;
case 'q':
system("exit");
default : break;
}
hOut=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, Position);
cout<<"s";
Sleep(200);
}
void choice(void *P){
keys=getch();
}