0

I have started implementing lookup. When I try to compile my code, the terminal gives an error when I try to assign one of my variables to another variable. The error says that I am trying to assign a "read-only" variable:

server.c:632:31: error: read-only variable is not assignable
                identify[num] = path[letter];  
                ~~~~~~~~~~~~~ ^
server.c:637:31: error: read-only variable is not assignable
                identify[num] = '\0';
                ~~~~~~~~~~~~~ ^

What does the compiler mean when it says "read-only" variable?

Here is my lookup code:

 //edited out

Thank you in advance.

1

When you use that keyword const, you're promising your compiler that you won't change the contents of what's inside the array. That's why the compiler yells... because you're trying to change it here identify[num] = path[letter]; and here identify[num] = '\0';

If you want to alter the contents of that array, you should declare it as a char array, not a const char array.

And you're starting the pset from the right place! Lookup() is what you should be implementing, so just go on doing what you're doing.

If this solves your problem, please click the check mark to accept the answer.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .