Errors on Thread Execution

I'm receiving compiler errors from the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**********************************************
Threads implementation
**********************************************/

#include<windows.h>
#include<iostream>
using namespace std;
struct DATA{
int age;
string fname,lname;
};
void function(DATA*pdata){
cout<<"The pointer to struct DATA :"<<pdata<<endl;
cout<<"Age :"<<pdata->age <<"Years."<<endl;
cout<<"First Name: "<<pdata->fname <<endl;
cout<<"Last Name :"<<pdata->lname <<endl;
Sleep(2000);
}
int main(){
DATA idata;
idata.age =10;
idata.fname ="Charlie";
idata.lname ="Junior";
DWORD tID;
HANDLE threadhandle=CreateThread(0,0,(LPTHREAD_START_ROUTINE)function,&idata,0,&tID);
if(INVALID_HANDLE_VALUE==threadhandle){
	cout<<"Error code :"<<GetLastError()<<endl;
}
/*wait for the thread to finish*/
while(WaitForSingleObject(threadhandle,3000)==WAIT_TIMEOUT){
	cout<<"Thread Execution Finished...."<<endl;
}
return 0;
}

The error are :
C:\programs\struct\struct.cpp(11) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversi
on)
C:\programs\struct\struct.cpp(12) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversi
on)
Can somebody help with this...Thanks
1
2
3
4
5
6
7
8
9
10
11
12
#include<windows.h>
#include<iostream>
#include <string>   /*ADD THIS INCLUDE FILE*/
using namespace std;
struct DATA{
int age;
string fname,lname;
};
.
.
.
.
Last edited on
Thanks ! guestgulkan it works.....!
Topic archived. No new replies allowed.