During compilation I receive a compiler error
#include<windows.h>
#include<iostream>
using namespace std;
typedef struct{
int a;
char name[7];
}params;
void print(params*lparam)
{
for(int i=0;i<10;i++){
cout<<"A in struct params is "<<lparam->a<<endl;
cout<<"Name in struct params is "<<lparam->name<<endl;
Sleep(5000);
}
void main()
{
params myparams;
myparams.a=1000;
myparams.name="joseph";
HANDLE threadhandle;
DWORD threadID;
threadhandle=CreateThread(0,0,(LPTHREAD_START_ROUTINE)print,&myparams,0,&threadID);
if(INVALID_HANDLE_VALUE==threadhandle)
{
cerr<<"Thread not created..."<<endl;
return -1;
}
//if threadcreated wait for execution to finish
while(WaitForSingleObject(threadhandle,9000)==WAIT_TIMEOUT){
cout<<"function execution fcompleted..."<<endl;
}
return 0;
}
I'm using VC++ 6.0 I receive the folowing compiler error and its the first I come across with such errors can somebody help...
the error says:
errorC2106:'=' :left operand must be l-value
From what I know a left operand is a variable or address.Thanks
There seem to be a number of thing with your code:
1: typedef stuct I assume that should be typedefstruct
2: void print(param*lparam), should that be params?
3: You open a block { in the print function but do not close it.
4: You have main defined as void and try to return a value;
and finally the bit that I assume is giving the error is myparams.name="joseph";, you will need to use a function to copy "joseph" into "myparams.name".
PS. please use code tags to post code: [code]your code goes here[/code]
Thanks for your advice It 's working .I have used the strcpy() function also I would like to know what the error meant I mean the lvalue error and how I get away with it.
Visual Studio Team System 2008 and Visual Studio 2005 Team Edition for Software developers. I also have Visual Studio 6 Enterprise Edition, for the older projects that have not been migrated.
Have done DirectX before? I'm still learning C++ I can say.But know I want to How my OS works before decide to something else.Your advice..!what should I do then...