int(*p)[]和int(**p)[]
1. int(*p)[10]:
根据运算符的结合律,()的优先级最高,所以p是一个指针,指向的一个维度为10的一维数组。
p一个指向数组的某一行
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]
这个的意义:q是一个指针,指向的元素就是1.中的p.
下面给一个例子:
#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;
}
int(*p)[]和int(**p)[]的更多相关文章
- Convert.ToInt32()、int.Parse()和(int)三者的区别
Convert.ToInt32将object类类型转换成int类型,如Convert.ToInt32(session["shuzi"]); (int)适合简单数据类型之间的转换: ...
- 深度解析C语言int与unsigned int
就如同int a:一样,int 也能被其它的修饰符修饰.除void类型外,基本数据类型之前都可以加各种类型修饰符,类型修饰符有如下四种:1.signed----有符号,可修饰char.int.Int是 ...
- C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别
转自:http://www.cnblogs.com/leolis/p/3968943.html 在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为 整型(int)来讲, ...
- what is difference in (int)a,(int&)a,&a,int(&a) ?
This interview question come from a famous communication firm of china. : ) #include <iostream> ...
- int(3)和int(10)的区别
int(M) 在 integer 数据类型中,M 表示最大显示宽度.在 int(M) 中,M 的值跟 int(M) 所占多少存储空间并无任何关系. int(3).int(4).int(8) 在磁盘上都 ...
- C#中(int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别 <转>
作者:Statmoon 出处:http://leolis.cnblogs.com/ 在编程过程中,数据转换是经常要用到的,C#中数据转换的方法很多,拿将目标对象转换为整型(int)来讲,有四种方法 ...
- 【C】二级指针探秘 & 星号的两种用法(1.与基本类型结合形成另一种类型,比如与int结合形成int* 2.取值操作)
1)问题:二级指针到底是什么?怎么用的?怎么存放的? #include <stdio.h> #define TEST_ADDR 0x12FF40 void main() { int a = ...
- int.Parse()、int.TryParse()和Convert.ToInt32()的区别
1:int.Parse(一个参数) 此参数必须满足: 1 只能是字符串: 2 只能是 “整型” 字符串,即各种整型ToString()之后的形式,也不能为浮点型. 2:int.TryPa ...
- (int)、int.Parse()、int.TryParse()和Convert.ToInt32()的区别
C#中(int).int.Parse().int.TryParse()和Convert.ToInt32()的区别 原文链接:http://www.cnblogs.com/leolis/p/3968 ...
- Java-集合-第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; 其中,classNum 表示学生的班号,例如“class05”。 有如下List List list = new ArrayList(); l
第三题 有如下Student 对象, private String name; private int age; private int score; private String classNum; ...
随机推荐
- 41. First Missing Positive(困难, 用到 counting sort 方法)
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] ...
- sessionStorage 、localStorage 和 cookie
localStorage 和 sessionStorage HTML5 提供了两种在客户端存储数据的新方法:localStorage 和 sessionStorage: 两者都是仅在客户端(即浏览器) ...
- 基本数据类型 异常 数组排序 JVM区域划分
Day01 1.基本数据类型各占几个字节 Byte 1 short2 int4 long8 float4 double6 char2 boolean1 Byte b1=3,b2= ...
- Oracle中备份用户对象的两种方法
方法1: 执行步骤: exp userid=用户名/密码@数据库名 file=c:\emp.dmp 使用当前用户导出 exp userid=sys/sys@数据库名 file=c:\emp.dmp o ...
- 0426html常用标签属性
一.基础语法 标签:作为网页的最小单元 1.双标签 内容的容器 2.单标签 控制性内容 注释 每一个模块都要写清楚注释 二.基本结构 <!DOCTYPE html> ...
- The type org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved.
最近自己练手写项目时,遇到了这个错,写个文章记录下, The type org.apache.commons.lang.exception.NestableRuntimeException canno ...
- Apache ActiveMQ实战(1)-基本安装配置与消息类型
ActiveMQ简介 ActiveMQ是一种开源的,实现了JMS1.1规范的,面向消息(MOM)的中间件,为应用程序提供高效的.可扩展的.稳定的和安全的企业级消息通信.ActiveMQ使用Apache ...
- Unable to ignore resources
摘要:分享牛,分享牛系列, Unable to ignore resources Attempted to beginRule: 异常信息处理. 出现Unable to ignore resource ...
- 剑指Offer——Java实现栈和队列的互模拟操作
剑指Offer--Java实现栈和队列的互模拟操作 栈模拟队列 题目:JAVA实现用两个栈来实现一个队列,完成队列的Push和Pop操作.队列中的元素为int类型. 思路:其实就是把队列正常入 ...
- [lua]luasocket.c:20:17: fatal error: lua.h: No such file or directory
安装luasocket的时候出现了如下的错误 问题 $ tar xzf luasocket-2.0.2.tar.gz $ cd luasocket-2.0.2 $ $ make cd src; mak ...