+ 7
Why there is an error at line foo[0]=1? Should it be foo[0]="1"?
include <stdio.h> int main() { const char* foo="hi"; foo="hello"; foo[0]=1; return 0; }
2 Answers
+ 5
You declared foo as pointing to a const char, so you can't change it.
+ 2
foo is an const char array, so firstly you canât change it, and secondly 1 is not a char; it is an integer, so there will be errors.