Hello,
I am playing around with pthreads. This program how ever blows up.
Quote:
#include <iostream>
#include <pthread.h>
using namespace std;
struct myStruct
{
int a;
string msg;
};
void * myProc(void *arg)
{
struct myStruct* str = new struct myStruct();
str->a = 10;
str->msg ="hi";
return (void*)str;
}
int main(int argc, char **argv)
{
pthread_t mythr;
int status ;
void *retVal;
struct myStruct* m_str;
status = pthread_create(&mythr,NULL,myProc,NULL);
status = pthread_join(mythr,&retVal);
cout<<"Status is"<<status<<endl;
m_str = (struct myStruct*)m_str;
cout<<"retval is "<<m_str->a<<" "<<endl;
return 0;
}
|
Can a structure be returned by a thread as its return value ?