c语言 int与byte[]互相转换
来源:互联网 发布:淘宝淘友在哪里看 编辑:程序博客网 时间:2024/05/16 14:14
gdb调试
root@ubuntu:/media/mtk6795/alps/sunwave_pub# gcc -g test.c root@ubuntu:/media/mtk6795/alps/sunwave_pub# gdb ./a.out GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04Copyright (C) 2012 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "x86_64-linux-gnu".For bug reporting instructions, please see:<http://bugs.launchpad.net/gdb-linaro/>...Reading symbols from /media/mtk6795/alps/sunwave_pub/a.out...done.(gdb) startTemporary breakpoint 1 at 0x40054c: file test.c, line 6.Starting program: /media/mtk6795/alps/sunwave_pub/a.out Temporary breakpoint 1, main () at test.c:66int a =257; (gdb) n7int a0=0,a1=0;(gdb) 8unsigned char * pBuf = NULL ;(gdb) 9int b=0;(gdb) 10pBuf = (unsigned char*) malloc(72*128*sizeof(unsigned char));(gdb) 13 pBuf[0] =(unsigned char)(a & 0xff);(gdb) 14pBuf[1] = (unsigned char)((a & 0xff00) >> 8);(gdb) 16 a0 = a%256;(gdb) 17 a1 = a/256;(gdb) 19printf("bruce int2byte ==>> pBuf[0]=%d,pBuf[1]=%d\n",pBuf[0],pBuf[1]);(gdb) bruce int2byte ==>> pBuf[0]=1,pBuf[1]=120printf("bruce int2byte ==>> a0=%d,a1=%d\n",a0,a1);(gdb) bruce int2byte ==>> a0=1,a1=123b =(int)(( pBuf[0] & 0xff )|((pBuf[1] & 0xff)<<8));(gdb) 24printf("bruce byte2int ==>> b=%d\n",b);(gdb) bruce byte2int ==>> b=25727return 0;(gdb) 28}(gdb)
c语言 int与byte[]互相转换
#include<stdio.h>#include<string.h>#include<math.h> #include<stdlib.h>int main(){int a =257; int a0=0,a1=0;unsigned char * pBuf = NULL ;int b=0;pBuf = (unsigned char*) malloc(72*128*sizeof(unsigned char));//int2byte pBuf[0] =(unsigned char)(a & 0xff);pBuf[1] = (unsigned char)((a & 0xff00) >> 8); a0 = a%256; a1 = a/256;printf("bruce int2byte ==>> pBuf[0]=%d,pBuf[1]=%d\n",pBuf[0],pBuf[1]);printf("bruce int2byte ==>> a0=%d,a1=%d\n",a0,a1); //byte2intb =(int)(( pBuf[0] & 0xff )|((pBuf[1] & 0xff)<<8));printf("bruce byte2int ==>> b=%d\n",b);return 0;}
1 0
- c语言 int与byte[]互相转换
- java byte 与int的互相转换
- int byte互相转换
- Java 将byte[] 与int类型互相转换
- java byte[] 与int float long 等的互相转换
- Socket编程int与byte array之间互相转换
- int与byte互相转换,1个int存储4个byte
- byte[]与int转换
- byte 与 int 转换
- C语言中byte类型与int类型转换与移位小细节记录
- byte[]与String互相转换
- CMSampleBufferRef与byte*互相转换
- C++int型与string型互相转换
- String 与 int 互相转换
- java 里byte int互相转换为什么要与0xff
- InputStream,int,shot,long与byte数组之间的互相转换
- InputStream,int,shot,long与byte数组之间的互相转换
- java int 与 byte转换
- Elasticsearch的特性
- MyBatis逆向工程(generatorsqlmapcustom)
- 动态分区的代码实现
- GUN Make 环境配置
- java中的动态加载类与静态加载
- c语言 int与byte[]互相转换
- jQuery修改form的action值并提交表单的方法
- 【Web前端】javascript作用域
- 递增牛群
- L1-005. 考试座位号
- Intent分为两大类,显性的(Explicit )的和隐性的(Implicit)
- AsyncBox的全局配置。
- 编辑测试
- RxJava语法练习