第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何增加指針地址和指針的值?

如何增加指針地址和指針的值?

C
溫溫醬 2019-12-07 15:45:23
讓我們假設(shè)int *p;int a = 100;p = &a;以下代碼將實(shí)際執(zhí)行什么操作以及如何執(zhí)行?p++;++p;++*p;++(*p);++*(p);*p++;(*p)++;*(p)++;*++p;*(++p);我知道,這在編碼方面有點(diǎn)雜亂無(wú)章,但是我想知道當(dāng)我們這樣編碼時(shí)實(shí)際會(huì)發(fā)生什么。注意:假設(shè)的地址a=5120300存儲(chǔ)在p地址為的指針中3560200?,F(xiàn)在,p & a每條語(yǔ)句執(zhí)行后的值是多少?
查看完整描述

3 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊

檢查了程序,結(jié)果是,


p++;    // use it then move to next int position

++p;    // move to next int and then use it

++*p;   // increments the value by 1 then use it 

++(*p); // increments the value by 1 then use it

++*(p); // increments the value by 1 then use it

*p++;   // use the value of p then moves to next position

(*p)++; // use the value of p then increment the value

*(p)++; // use the value of p then moves to next position

*++p;   // moves to the next int location then use that value

*(++p); // moves to next location then use that value


查看完整回答
反對(duì) 回復(fù) 2019-12-07
?
慕仙森

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

關(guān)于“如何增加指針地址和指針的值?” 我認(rèn)為這++(*p++);實(shí)際上是定義明確的,并且可以滿足您的要求,例如:


#include <stdio.h>


int main() {

  int a = 100;

  int *p = &a;

  printf("%p\n",(void*)p);

  ++(*p++);

  printf("%p\n",(void*)p);

  printf("%d\n",a);

  return 0;

}

它不是在序列點(diǎn)之前兩次修改同一件事。我認(rèn)為對(duì)于大多數(shù)用途而言,這不是一個(gè)好風(fēng)格-對(duì)我來(lái)說(shuō)有點(diǎn)神秘。

查看完整回答
反對(duì) 回復(fù) 2019-12-07
  • 3 回答
  • 0 關(guān)注
  • 721 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)