iT邦幫忙

0

想知道指標運算是怎麼在這個程式裡做運算的,ANS1=12、ANS2=14 (;´༎ຶД༎ຶ`)

  • 分享至 

  • twitterImage

#include
using namespace std;
int func(int x, int& y, int* z)
{
x=x+1;
y=y+2;
z=&x;
return x+y+*z;
}
int main()
{
int a=2, b=4, c=6;
printf("ANS1=%d", func(a, b, &c));
printf("\nANS2=%d", a+b+c);
return 0;
}

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
海綿寶寶
iT邦大神 1 級 ‧ 2022-08-08 14:36:20
最佳解答

先看一下下圖
單純英文字母是「變數」
前面加了&的是「位址」
https://ithelp.ithome.com.tw/upload/images/20220808/20001787QrM8qBy8s5.png
有問題再提出

我要發表回答

立即登入回答