日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

指針是一個存儲另一個變量地址的變量。

指針的特點

    指針節省內存空間。

    由于直接訪問內存位置,指針的執行時間更快。

    在指針的幫助下,內存被有效地訪問,即動態分配和釋放內存。

    指針與數據結構一起使用。

    聲明一個指針

    int *p;

    登錄后復制

    這意味著“p”是一個指針變量,它保存另一個整型變量的地址。

    指針的初始化

    地址運算符(&)用于初始化指針變量。

    例如,

    int qty = 175;
    int *p;
    p= &qty;

    登錄后復制

    通過變量訪問變量指針

    要訪問變量的值,請使用間接運算符 (*)。

    程序

    ?現場演示

    #include<stdio.h>
    void main(){
       //Declaring variables and pointer//
       int a=2;
       int *p;
       //Declaring relation between variable and pointer//
       p=&a;
       //Printing required example statements//
       printf("Size of the integer is %d

    ",sizeof (int));//4// printf("Address of %d is %d

    ",a,p);//Address value// printf("Value of %d is %d

    ",a,*p);//2// printf("Value of next address location of %d is %d

    ",a,*(p+1));//Garbage value from (p+1) address// printf("Address of next address location of %d is %d

    ",a,(p+1));//Address value +4// //Typecasting the pointer// //Initializing and declaring character data type// //a=2 = 00000000 00000000 00000000 00000010// char *p0; p0=(char*)p; //Printing required statements// printf("Size of the character is %d

    ",sizeof(char));//1// printf("Address of %d is %d

    ",a,p0);//Address Value(p)// printf("Value of %d is %d

    ",a,*p0);//First byte of value a - 2// printf("Value of next address location of %d is %d

    ",a,*(p0+1));//Second byte of value a - 0// printf("Address of next address location of %d is %d

    ",a,(p0+1));//Address value(p)+1// }

    登錄后復制

    輸出

    Size of the integer is 4
    Address of 2 is 6422028
    Value of 2 is 2
    Value of next address location of 2 is 10818512
    Address of next address location of 2 is 6422032
    Size of the character is 1
    Address of 2 is 6422028
    Value of 2 is 2
    Value of next address location of 2 is 0
    Address of next address location of 2 is 6422029

    登錄后復制

    以上就是編寫一個C程序,演示指針的示例的詳細內容,更多請關注www.xfxf.net其它相關文章!

分享到:
標簽:指針demopro()
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定