c指针-01

#include <stdio.h>
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.csdn.net/huangblog/article/details/8362804

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值