char和short 给int赋值或与int比较时 需要特别注意
2014-08-15 10:56
204 查看
#include <stdio.h>
int main()
{
int a;
char c =0x81;
a = c;
printf("%x\n", a); //0xffffff81
}
#include <stdio.h>
int main()
{
int a;
char c =0x81;
a = c & 0xff;
printf("%x\n", a); //0x81
}
#include <stdio.h>
int main()
{
char buf[8];
buf[0] = 1;
buf[1] = 0xf2;
if(buf[0] == 1)
printf("buf0 == 1\n");
if(buf[1] == 0xf2)
printf("buf1 == 0xf2\n");
printf("aa:%x\n", aa); //f2
printf("buf1:%x\n", buf[1]); //fffffff2
}
int main()
{
int a;
char c =0x81;
a = c;
printf("%x\n", a); //0xffffff81
}
#include <stdio.h>
int main()
{
int a;
char c =0x81;
a = c & 0xff;
printf("%x\n", a); //0x81
}
#include <stdio.h>
int main()
{
char buf[8];
buf[0] = 1;
buf[1] = 0xf2;
if(buf[0] == 1)
printf("buf0 == 1\n");
if(buf[1] == 0xf2)
printf("buf1 == 0xf2\n");
printf("aa:%x\n", aa); //f2
printf("buf1:%x\n", buf[1]); //fffffff2
}
相关文章推荐
- int、short、char 类型超出范围赋值__说说原码,反码,补码
- 写正确函数需要注意的地方:int转char*, char* 转int。
- int、short、char 类型超出范围赋值__说说原码,反码,补码
- int、short、char 类型超出范围赋值__说说原码,反码,补码
- 关于Java中byte,short,char,int 之间相互赋值的问题
- int、short、char 类型超出范围赋值问题__原码,反码,补码
- int、short、char 类型超出范围赋值,说说原码,反码,补码。
- int、short、char 类型超出范围赋值
- 把QString转换成 char * 中需要注意的地方
- 特别注意:Delphi数组的赋值,SetLength没有作用
- 我在程序中这么做f1==f2,可是明明相等但是程序中却按不相等的去做了。难道浮点数比较还有什么需要注意的问题吗?
- Mybatis特别注意int类型的数据判断
- java中byte、short、char、int的转换
- c语言基本数据类型short、int、long、char、float、double
- char short int long float double
- SqlServer中使用Select语句给变量赋值的时候需要注意的一个问题
- Fragment 出栈的方法popBackStack需要特别注意的一点
- 系统出现bootmgr is missing解决方案,戴尔dell服务器装系统需要特别注意的问题
- char,short ,int ,long,long long,unsigned long long数据范围
- java对byte,short,char,int,long运算时自动类型转化情况说明