[問題] 有關 short 轉double 問題
開發平台(Platform): (Ex: Win10, Linux, ...)
QT 5.10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
qt creator4.5.1
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
short tempData[10];
*(int *)tempData = 1;
*(double *)&tempData[1]=100;
qDebug() << " " << tempData[0];
qDebug() << " " << tempData[1];
請問為什麼 轉int結果是對的
但是double 卻是0呢
c++新手 求各位幫幫我 感謝
其中qDebug 相當於 cout
預期的正確結果(Expected Output):
1
100
錯誤結果(Wrong Output):
1
0
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 218.35.154.241
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1532976920.A.C56.html
噓
07/31 04:14,
6年前
, 1F
07/31 04:14, 1F
→
07/31 04:15,
6年前
, 2F
07/31 04:15, 2F
→
07/31 04:17,
6年前
, 3F
07/31 04:17, 3F
推
07/31 04:41,
6年前
, 4F
07/31 04:41, 4F
→
07/31 15:34,
6年前
, 5F
07/31 15:34, 5F
→
08/01 20:47,
6年前
, 6F
08/01 20:47, 6F
→
08/01 20:47,
6年前
, 7F
08/01 20:47, 7F