c指针-01
来源:互联网 发布:淘宝的免费开店是什么 编辑:程序博客网 时间:2024/06/06 00:23
#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;
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
- C和指针01
- c指针-01
- 新手谈C指针01_指针?
- C语言基础-01-指针
- C指针的指针
- c 指针的指针
- C--指针
- C-指针
- C指针
- C指针
- C指针
- C---指针
- c 指针
- C指针
- C指针
- C指针
- C 指针
- c指针
- Objective-C字符串处理方法大全
- Mac 连接外设键盘command冲突
- Win10下MxNet安装手记
- MongoDB数据文件内部结构
- Tomcat修改IP访问为绑定域名访问
- c指针-01
- Android 深入理解Android中的自定义属性
- Spring 定时任务之 @Scheduled cron表达式
- 使用nodejs+express(4.x+)实现文件上传
- Android Bluetooth Low Energy官方文档翻译
- 剑指Offer:面试题29——数组中出现次数超过一半的数字(java实现)
- CreateThread和_beginthreadex区别
- 树、森林和二叉树的转换
- mac xcode7编译老版本程序程序出错