看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《pioneerLike (~小耿~)》之銘言: : 不知道怎麼下標題好 : #include <stdio.h> : #include <stdlib.h> : #include <string.h> : int main() { : char *a = new char[100]; : char *b = (char *)malloc(100*sizeof(char)); : char c[100] ; : printf("[%p] [%p]\n",a,&a) ; // not same stack heap &a| a | a|*a | : printf("[%p] [%p]\n",b,&b) ; // not same stack heap &b| b | b|*b | : printf("[%p] [%p]\n",c,&c) ; // the same &c是指標 指到第一個元素 c是陣列 只是這裡被compiler換成指標 : system("PAUSE"); : } : 小弟百思不得其解,查了很多資料依然不明白其中原理的差異,請板友解惑,謝謝=] 來,跟我說一次"陣列不等於指標" -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.252.74.195
meconin:其實有趣的應該是 (c = &c = *&c) != (*c = **&c) 11/09 18:05
meconin:推錯篇 ... 11/09 18:09
loveme00835:樓上... http://ppt.cc/Sa(, 11/09 18:30
meconin:把 include 換回 c 的。http://codepad.org/McSEbBKk 11/09 18:42
loveme00835:傻眼... 11/09 19:06
loveflames:那我要推一下這個 http://codepad.org/QZw62kPG 11/09 19:07