|
| charlie (31) | |||
| 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 | |||
| Grey Wolf (1133) | |||
| There seem to be a number of thing with your code: 1:
typedef stuct I assume that should be
typedef struct 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] | |||
| charlie (31) | |||
Thank for your advice It 's working .I have used the
strcpy() function | |||
| charlie (31) | |||
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. | |||
| Grey Wolf (1133) | |||
| error C2106:'=' :left operand must be l-value An l-value is one that can appear on the left side of an assignment, so it is basically saying you can not assign a new value to the left hand side. I must admit I would have expected the error to be along the lines of error C2440: '=' : cannot convert from 'const char [7]' to 'char [7]' | |||
| charlie (31) | |||
| I don't know but that is way it appeared on my compiler error.hope you don't mind me asking which compiler are you using ?mine is vc++ 6.0 ... | |||
| Grey Wolf (1133) | |||
| 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. | |||
| charlie (31) | |||
| 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... | |||
| Zaita (2092) | |||
I would suggest using
strncpy() instead of
strcpy() or
snprintf() (not
sprintf().
strcpy() is not save from buffer overflows, it's generally considered bad practice to use it.Edit: I'd also suggest using
string instead of character arrays and pointers to characters. (e.g
char *) | |||
| charlie (31) | |||
| Thanks Zaita...OK now it's time for your advice ...! | |||
| Grey Wolf (1133) | |||
| Do you want to know the internal working of Windows, or how to write Windows native code? | |||
| charlie (31) | |||
| I wanna know how the internal workings of windows...... | |||
This topic is archived - New replies not allowed.
