亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

深入解析int(*p)[]和int(**p)[]

 更新時(shí)間:2013年07月11日 10:50:47   作者:  
以下是對(duì)int(*p)[]和int(**p)[]的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以參考下
1. int(*p)[10]:
根據(jù)運(yùn)算符的結(jié)合律,()的優(yōu)先級(jí)最高,所以p是一個(gè)指針,指向的一個(gè)維度為10的一維數(shù)組。
p一個(gè)指向數(shù)組的某一行
復(fù)制代碼 代碼如下:

int a[1][4]={1,2,3,4};
    int (*p)[4] = a;//p point to the row of array a
    for(int i=0;i<4;i++)
    {
     cout<<*((*p)+i)<<" ";
    }

2. int(**q)[10]
這個(gè)的意義:q是一個(gè)指針,指向的元素就是1.中的p.
下面給一個(gè)例子:
復(fù)制代碼 代碼如下:

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a[2][2]={1,2,3,4};
    int (*p)[2] = a;//p point to the row of array a
    for(int i = 0;i<2;i++)//output matrix using p
    {
            for(int j = 0;j<2;j++)
            {
                    cout<<*(*(p+i)+j)<<" ";
            }
            cout<<endl;
    }
    int (**q)[2] = &p;//q point to p
    for(int i = 0;i<2;i++)//output matrix using q
    {
            for(int j = 0;j<2;j++)
            {
                    cout<<*(*(*q+i)+j)<<" ";
            }
            cout<<endl;
    }

    getchar();
    return 0;
}

相關(guān)文章

最新評(píng)論