开发平台(Platform): (Ex: Win10, Linux, ...)
WIN10
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
visual studio 2019
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
问题(Question):
喂入的资料(Input):
预期的正确结果(Expected Output):
hello 0x440000
world 0x440008
错误结果(Wrong Output):
E0144 类型 "const char *" 的值无法用来初始化类型 "char *" 的实体
E0513 类型 "const char *" 的值无法指派至类型 "char *" 的实体
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
#include <iostream>
using namespace std;
int main() {
char* str = "hello";
void* add = 0;
add = str;
cout << str << "\t"
<< add << endl;
str = "world";
add = str;
cout << str << "\t"
<< add << endl;
return 0;
}
补充说明(Supplement):
按照网站的教学宣告一个字符的指标
但是编译却出错误
直接复制网站的也是这样
请问是什么问题呢
网站教的是错的吗?