Function returning a const char *
cannot be assigned to char*
const char* func() {
return "This is a const string two ";
}
but char*
is assigned a constant string in main directly:
int main() {
char *d =" this is a const string one"; // works fine
char *e = func(); // error cannot convert from 'const char *' to 'char *'
return 1;
}
Why the contradiction?