[問題] ->與點
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
devc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
不好意思, 又卡住了
我曉得 取結構體元素值可以 pp->x 或pp.x
但是, 不曉得為什麼這邊用pp.x會報錯, pp->x就可以
因為當我打點時, 他會出現x給我選, 但選完卻報錯.
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
程式1
#include <stdio.h>
typedef struct MyPoint{
int x;
int y;
} * PP;
struct MyPoint point ={20,40};
int main(int argc, char *argv[]) {
PP pp = &point;
printf("x=%d\n",pp->x);
printf("y=%d\n",pp->y);
return 0;
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.251.229.117
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1440321936.A.67A.html
推
08/23 17:32, , 1F
08/23 17:32, 1F
ㄚ!謝了~我知道了!!
printf("x=%d\n",(*pp).x);
printf("y=%d\n",(*pp).y);
※ 編輯: GooLoo (111.251.229.117), 08/23/2015 17:39:12
推
08/23 18:41, , 2F
08/23 18:41, 2F
→
08/23 18:42, , 3F
08/23 18:42, 3F
→
08/23 19:27, , 4F
08/23 19:27, 4F
推
08/23 23:36, , 5F
08/23 23:36, 5F
→
08/23 23:36, , 6F
08/23 23:36, 6F
推
08/24 13:18, , 7F
08/24 13:18, 7F
→
08/25 00:45, , 8F
08/25 00:45, 8F