[問題] 請問關於指標問題
下面是我剛剛在自己學指標 發現的問題
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
int *a;
int b=5;
a=&b;
printf("%d\n",a);
printf("%d\n",&b);
printf("%d\n",&a);
printf("%d\n",*a);
int *c;
int* test1(int* a);
//********************** 問題一 請問我為什麼一定要寫成這樣 才能編譯過 我本來想寫的是
/*
a=test1(a);
printf("-----------------\n");
printf("%d\n",*a);
*/
a=test1(a);
c=test1(a);
printf("-----------------\n");
printf("%d\n",*c);
//**********************
system("pause");
}
int* test1(int* a)
{
//*********************
//問題二 我本來想寫這樣 但得到的答案看起來想記憶體位址 為什麼會這樣
/*
int* x;
int y=0;
x=&y;
*x=*a * *a;
return x;
*/
//*******************
*a=*a * *a;
return a;
}
--
╲ ◢▅◢▅◣ ╱ 親愛的妳要找什麼阿~◢██ ◣◢███◣ 在前面!!!
◤◥◥█◣ ◢◢◢█ █◥◥█◢ 我找到了!
● ● ◤ 為什麼...我的心裡 ▏ ◢ ● ● ◢◣ 你在這邊
─ ◣-- ◢ ─ 會有種蛋蛋的哀傷呢? ◣▽ ◢ ◣▼ ◢ ◢ 等我一下唷~
◢ 馬 ◣ ﹑ 。 ◢ 驢 ◣◣ ◣
╱ < ▂▂▂◣╯ ╲ 。 < ▂▂▂▂▂▂▂◣╯
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.105.76
推
07/03 10:21, , 1F
07/03 10:21, 1F
→
07/03 10:23, , 2F
07/03 10:23, 2F
→
07/03 10:23, , 3F
07/03 10:23, 3F
→
07/05 23:11, , 4F
07/05 23:11, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章