DaRedMonkey
IS-IT--Management
I got the following code and it gave me the following error: line 121: error 1549: Modifiable lvalue required for assignment operator
Here's the code snippet:
char lot_prefix[2], proddir[20]
strncpy(lot_prefix, lot_no, 2);
if ( (strncmp(lot_prefix[1],"F",1) == 0) || (strncmp(lot_prefix[1],"I",1) == 0) || (strncmp(lot_prefix[1],"L",1) == 0) )
{
proddir = "Food";
} else if ( (strncmp(lot_prefix[1],"D",1) == 0) || (strncmp(lot_prefix[1],"G",1) == 0) || (strncmp(lot_prefix[1],"P",1) == 0) )
{
proddir = "Garden";
} else if ( (strncmp(lot_prefix[1],"E",1) == 0) || (strncmp(lot_prefix[1],"J",1) == 0) || (strncmp(lot_prefix[1],"M",1) == 0) )
{
proddir = "Automotive";
} else if ( (strncmp(lot_prefix[1],"K",1) == 0) || (strncmp(lot_prefix[1],"R",1) == 0) )
{
proddir = "Electronic";
} else if ( (strncmp(lot_prefix[1],"T",1) == 0) )
{
proddir = "Book";
} else
{
print "Sorry, You need to add the new product to the program before you can use it. \n";
}
I also tried to do it using switch-case statement but also having problem:
switch (lot_prefix[1]) {
case 'P':
proddir = "Food";
break;
case 'I':
proddir = "Garden";
break;
case 'T':
proddir = "Automotive";
break;
case 'F':
proddir = "Electronic";
break;
default:
proddir = "other";
}
Also, Can I do this with the case statement? case 'T|V|K' or can I do this case 'T' | 'V' | 'K'
I remember vaguely that you can do something like that.
--DRM