開發平台(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):
按照網站的教學宣告一個字元的指標
但是編譯卻出錯誤
直接複製網站的也是這樣
請問是什麼問題呢
網站教的是錯的嗎?