Why can a string literal be implicitly converted to char* only in certain case? [duplicate]
问题 This question already has answers here : Why is passing a string literal into a char* argument only sometimes a compiler error? (6 answers) Closed 6 years ago . void f(char* p) {} int main() { f("Hello"); // OK auto p = "Hello"; f(p); // error C2664: 'void f(char *)' : cannot convert parameter 1 // from 'const char *' to 'char *' } The code was compiled with VC++ Nov 2012 CTP. §2.14.15 String Literals, Section 7 A narrow string literal has type “array of n const char”, where n is the size of