int a[3];

a 和 &a 的地址一样的。

a+1 == a + 1*sizeof(int);跳跃是一个数组元素大小

&a+1 == a + 3*sizeof(int);跳跃是整个数组大小

#include <stdio.h>

int
main()
{
char * a[] = {"hello","the","world"};
char ** pa = a;
pa ++; /* 获取数组中第二个元素 */
printf("*pa = %s\n",*pa);
printf("*(a+1) = %s\n",*(a+1)); int b[] = {1,2,3};
int * pb = b; /* 获取数组中最后一个元素 */
printf("*((int *)(&b +1)-1) = %d\n",*((int *)(&b +1)-1));
printf("*((int *)((&b +1)-1) = %d\n",*((int *)((&b +1)-1))); printf("*((char **)(&a+1)-1) = %s\n",*((char **)(&a+1)-1)); /* 地址一样 */
printf("b = 0x%0X\n",b);
printf("&b = 0x%0X\n",&b);
}
/*
[root@localhost test_class]# ./a.out
*pa = the
*(a+1) = the
*((int *)(&b +1)-1) = 3
*((int *)((&b +1)-1) = 1
*((char **)(&a+1)-1) = world
b = 0xBFC556B0
&b = 0xBFC556B0
*/

int a[3];中a+1与&amp;a+1差别 -- C的更多相关文章

  1. 75 int类型数组中除了一个数出现一次或两次以外,其他数都出现三次,求这个数。[2行核心代码]

    [本文链接] http://www.cnblogs.com/hellogiser/p/single-number-of-array-with-other-three-times.html [题目] i ...

  2. MyBatis mapper文件中的变量引用方式#{}与${}的差别

    MyBatis mapper文件中的变量引用方式#{}与${}的差别 #{},和 ${}传参的区别如下:使用#传入参数是,sql语句解析是会加上"",当成字符串来解析,这样相比于$ ...

  3. Javascript 中 的 for ... in 和 for ... of 差别

    Javascript 中 的 for ... in 和 for ... of 差别 for ... in 是历史问题,在循环数据时会可以出现奇怪的问题,比如把数据的属性循环出来. for ... of ...

  4. ][mybatis]MyBatis mapper文件中的变量引用方式#{}与${}的差别

    转自https://blog.csdn.net/szwangdf/article/details/26714603 MyBatis mapper文件中的变量引用方式#{}与${}的差别 默认情况下,使 ...

  5. 数组溢界地址的正确使用: 即 int a[6] 中的 a[-1] 和 a[6] 正确使用

    正如大家所知道的那样: 数组  int a[6] ,  编译器阅读到这句数组定义,会为分配6个int 类型的地址:a[0]  a[1]   a[2]   a[3]  a[4]  a[5].我们 能够正 ...

  6. int型整数中2进制中含有1的个数。

    int func(x) { int countx =0; while(x) { countx ++; x = x&(x-1); } return countx; } 解释下思路: 1.任何一个 ...

  7. int('x', base)中的base参数

    >>> int('12', 16) 16表示'12'就是16进制数,int()要将这个16进制数转化成10进制.

  8. Java中string 创建对象时 “”和null的差别

    null和""的差别 问题一: null和""的差别 String s=null; string.trim()就会抛出为空的exception String s ...

  9. [JSP]JSP中include指令和include动作的差别

    include指令是编译阶段的指令,即include所包括的文件的内容是编译的时候插入到JSP文件里,JSP引擎在推断JSP页面未被改动,否则视为已被改动. 因为被包括的文件是在编译时才插入的.因此假 ...

随机推荐

  1. ftp服务器搭建(windows)+实现ftp图片上传对接

    ftp服务器搭建(windows): vsftpd简介: vsftpd是“very secure FTP daemon”的缩写,是一个完全免费的.开放源代码的ftp服务器软件. 下载地址: http: ...

  2. 静态链接和动态链接库混用导致的链接错误LINK2005

    对于一个静态链接库L.lib,它的使用者app.exe会静态链接L.lib,意思是app.exe会将L.lib中的代码(app需要的部分,例如函数定义,类的定义等等)链接到app.exe中.   而对 ...

  3. Java错误随手记

    一.Eclipse启动时提示: An internal error occurred during: "Initializing Java Tooling" 1.关闭Eclipse ...

  4. tomcat 异常:Caused by: org.apache.catalina.LifecycleException: The connector cannot start since the specified port value of [-1] is invalid

    启动tomcat时出现异常: org.apache.catalina.LifecycleException: Failed to start component [Connector[AJP/1.3- ...

  5. gitlib 安装

    参考文件https://www.cnblogs.com/rslai/p/9109624.html

  6. 利用Redis生成业务流水号思路

    系统需要生成根据业务类型生成流水号,每天从1开始生成,第二天会清零继续从0开始,流水号格式为: bizCode + date + incr  如:TT-2017112300001. 思路:利用Redi ...

  7. hdu 5720(贪心+区间合并)

    Wool Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Subm ...

  8. springBoot Ribbon Hystrix

    1.依赖包引入 <!-- 引入关于 hystrix的依赖 --> <dependency> <groupId>org.springframework.cloud&l ...

  9. VirtualBox安装部署的Ubuntu16.04的步骤

    1.下载ubuntu16.04镜像 http://cn.ubuntu.com/download/ 以及虚拟机软件VirtualBox https://www.virtualbox.org/wiki/D ...

  10. [BZOJ1294][SCOI2009]围豆豆Bean 射线法+状压dp+spfa

    1294: [SCOI2009]围豆豆Bean Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 458  Solved: 305[Submit][Sta ...