Expression must be a modifiable L-value

lvalue means “left value” — it should be assignable. You cannot change the value of text since it is an array, not a pointer.

Either declare it as char pointer (in this case it’s better to declare it as const char*):

const char *text;
if(number == 2) 
    text = "awesome"; 
    text = "you fail";

Or use strcpy:

char text[60];
if(number == 2) 
    strcpy(text, "awesome"); 
    strcpy(text, "you fail");

Leave a Comment