Because the const char* and char * types do not match
There are three ways to solve it:
- Use casts:
char str = "hello world"; //错误代码 双引号
char str = (char)"hello world";//正确代码 使用强制类型转换
- Use character arrays for storage first, and then use pointers:
char str[] = "hello world";
- Right-click on the project, select "Properties", select "C/C++", and then in "Language", change "Conform to Mode" to "No".