I'm writing a little function in C that eliminates leading whitespace, but it's giving me the "expression must be a modifiable lvalue"
char str1[20];
strcpy (str1, otherStr);
for (int i = 0; i < strlen(str1); i++)
{
if (!isspace(str1[i]))
str1 = &(str1[i]);
}
What am I doing wrong here? (And yes, otherStr is defined)
There's no
char *pointer in your code, which one could possibly change. Array is not a pointer. You can't "change" its location.In C language arrays objects themselves are non-modifiable lvalues, which is where the wording of the error stems from.