problem using cin inside DWORD Thread

hello guys this is my first post
am trying to take input from console using cin from a thread
when i enter the characters and press enter the program crashes
i think it`s a dead lock but in io console or something like that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

DWORD WINAPI ThreadProc (LPVOID lpdwThreadParam );
DWORD WINAPI ThreadProc (LPVOID lpdwThreadParam )
{
	
	 
				cin >> statename;
		
				takingState=true;
		
	
				return 0;

			};




inside the main

1
2
3
4
5
6
7
8
9
10
11
12
13
DWORD dwThreadId  =7;

				printf("inside the tread  \n");

				hThread= CreateThread(NULL, //Choose default security  
	 0, //Default stack size
(LPTHREAD_START_ROUTINE)&ThreadProc,
//Routine to execute
(LPVOID) &i, //Thread parameter
0, //Immediately run the thread
&dwThreadId //Thread Id
) ;



Maybe you forgot to allocate statename? Also, I don't think it's a good idea to use cin inside a thread...
Topic archived. No new replies allowed.