Error: Assignment of read-only location in C
Error: assignment of read-only location occurs when we try to update/modify the value of a constant, because the value of a constant cannot be changed during the program execution, so we should take care about the constants. They are read-only.
Consider this example:
Output
Here, the statement str[0]='p' will try to change the first character of the string, thus, the "Error: assignment of read-only location" will occur.
How to fix?
Do not change the value of a constant during program execution.
need an explanation for this answer? contact us directly to get an explanation for this answer