I need a deep technical explanation of what I'm about to ask, not a solution.
Ive been learning pointers for a week now, I understand it pretty well. But while writing a program, I stumbled upon this error:
cannot convert ‘const std::string’ to ‘const char*’ for argument ‘2’ to ‘char* strcpy(char*, const char*)’
So I solved pretty easily with string.c_str()
no problem. But I got very interested into why this is. I have been searching like crazy why a const string is not the same a const
char *. When people explain a string they say its no different than a char *, so why does adding a const before the string not make it a const char *
?