03-16-2009 05:29 AM
hello,
can everybody tell me what is wrong in the code??
Error: Array assignments are illegal / Lvalue required.
thx
int CVICALLBACK GenerateCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
char tmpLastStep[NAME_SIZE];
switch (event)
{
//set the last step at LAST
tmpLastStep = LAST;
case EVENT_COMMIT:
if( 0 == strcmp(tmpLastStep, "LAST" ) )
{
MessagePopup("Last Step","Here is the last step." ) ;
CCSTemp.i16Step = LAST;
CCSTemp.i16Fkt = FKT_END;
}
else
{
MessagePopup("Error","Error in Stepfile. Last Step not defined." ) ;
error_write_main = 1;
}
WriteStepFile(ARRAYID, ARRAYPORT, ARRAYBAUD, ARRAYCALCULATION, ARRAYCHARACTISATION, ARRAYFILES,
ARRAYORDNER);
break;
}
return 0;
}
03-16-2009 06:07 AM
the error tells you that array assignment is illegal.
look at your code, what array do you have ? only one, tmpLastStep.
Is it assigned somewhere ? yes, line 8, tmpLastStep = LAST;
what is the problem with this assignment ? first, we don't know the value of LAST, is it a string as this strcmp() later suggest, or is it an int as the rest of the code suggest (i16Step, the useless hungarian notation is useful here to tell that this variable is a short int) ? second, assignment of a value to an array is illegal: there is a lot of reasons why this is this way (it is a reason of pointer and where the memory for the array is allocated), for the moment remember to never ever set your array this way ! to copy the content of an array to another array, use standard functions like memcpy() or strcpy().
another problem: the array assignment is INSIDE the switch but OUTSIDE any case statement, thus will NEVER be executed...watch out when you are writing code.
03-16-2009 06:09 AM - edited 03-16-2009 06:10 AM
OK - I was beaten to the keyboard!
03-16-2009 06:50 AM
jr_2005 wrote:
"OK - I was beaten to the keyboard!"
i hope it did not hurt... i will try beating softer next time.
03-16-2009 07:07 AM
dummy_decoy wrote:i hope it did not hurt... i will try beating softer next time.
You people are so polite. Kudos to both of you. Enjoy