数组
来源:互联网 发布:java 个性签名演示 编辑:程序博客网 时间:2024/06/06 08:48
地址:
int a=22;
printf("a的地址是: %d\n",&a);
打印出来的就是a的地址。
//定义一维数组
定义: 类型 数组名【行数】
int ages[5];
int ages['b'];
int ages[3*4];
int ages[]={1,22};
//wrongs
int ages[];
int i=9;
int ages[i];
数组不能整体赋值,除非在定义的时候是可以的。
int ages[2]={1,22};是对的
但是 int ages[2]; ages={1,22}是错误的
ages[2]={1,22}也是错误的,因为ages[2]代表的是一维数组的第2个值,赋值给的却是数组。
【】里边可以是固定值,常量,常量表达式,但不能不指定数组长度或者是用变量。数组的存储空间是连续的,数组名代表着整个数组的地址,也就是数组的起始地址。
怎么拿到数组的地址呢?1。 ages 2. &ages[0]
思考:怎么调换数组里边的值?
二维数组
定义: 类型 数组名【行数】【列数】
二维数组是特殊的一维数组,他的元素是一维数组。
怎么拿到二维数组的地址呢?1。 ages 2. &ages[0][0] 3 ages[0]
列数绝对不能省略
0 0
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- MongoDB 运维管理
- Cocos2d-x手动绑定C++类到Lua
- 推荐系统之反面案例
- fwrite和fread函数的用法小结
- 我知识积累的第一篇章
- 数组
- How do you build a database?
- java 集合类中的性能PK
- #296 (div.2) C.Glass Carving
- android仿多看阅读三屏滚动效果 -- 更改OnPageChangeListener
- Unity4.6.3编译android版本报错,Creating directory failed
- 栋栋晓02:jQuery基础知识(转)
- 作业P51-11
- 编译原理课程设计-PL/0编译器的扩充(C语言完整版)