Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - About C++: Why can string constants be assigned to character pointers, but integer constants cannot be assigned to integer pointers?
About C++: Why can string constants be assigned to character pointers, but integer constants cannot be assigned to integer pointers?

For a string like "hello", its type in C/C++ is a character array: char[6] (note, not const char[6], because C language does not have this type, C++ It must also be backward compatible with C). Character arrays can be assigned to character pointers.

But const char* cannot be replaced by char*.