int main(void)
{
char* p = NULL;
char* tmp = "12345678";
p = (char* )(tmp+4);
printf("%c\n",*p);
//p[-1] = ?,p[-5] = ?
//printf("%c",p[-1]);//4
printf("%c\n",p[-2]);//3
printf("%c",p[-5]);//null
//我猜测,加上负号应该是索引倒过来
//加上负号表示从当前开始建立倒立的索引
return 0;
}
//这里有个没有弄懂的
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char* data = "12345678";
short* tmp = NULL;
char p[6] = {0};
tmp = (short *)&p[2];
*tmp = atoi(&data[4]); //库函数将字符串转换为长整形数
//同理atof把字符串转换成浮点数
//p[0] = ?, p[1] = ?, p[2] = ?, p[3] = ?, p[4] = ?, p[5] = ?。
//p[2]p[3]的值改变,值为什么是4622而不是5678
//printf("%s",&data[4]);//5678因为data是char指针类型
printf("%u\n",p[0]);
printf("%u\n",p[1]);
printf("%u\n",p[2]); //46
printf("%u\n",p[3]); //22
printf("%u\n",p[4]);
printf("%u\n",p[5]);
return 0;
}
关于指针我只理解基本概念,一般使用,这次的深入一点的探究只是一时兴趣
这些资源来自 网站http://blog.youkuaiyun.com/huangblog/article/details/8362804