Blog Content
ISO C++11 does not allow conversion from string literal to ‘char *‘
C/C++
2012-05-29 13:09:14
c++ 11时报错。
报错代码:
char *p = "xiao ming";
这在C++11标准中是错误的,会认为“xiao ming”是字符常量,定义一个指针去指向它,这样是有问题的,正确的定义方式是:
const char *p = "xiao ming";
这样在编译的时候才不会报错!
上一篇:h文件中报错 unterminated conditional directive的原因
下一篇:C++ 将string转换成char*字符串