69,371
社区成员
发帖
与我相关
我的任务
分享
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char c1=159;
unsigned char c2=17;
printf("c1 is %x, c2 is %x. \n", c1, c2);
printf("c1 is %d, c2 is %d. \n", c1, c2+7);
system("pause");
return 0;
}
#include <stdio.h>
int main()
{
char c1=16;
int t1=c1;
printf("c1=%x, t1=%x\n", c1, t1);
printf("c1=%d, t1=%d\n", c1, t1);
return 0;
}
如果你的char里面是字符型的数字
#include <stdio.h>
int main()
{
char c1='9'; //只能存一位,想存9以是的,就得用16进制表示
char pc1[2];
int t1;
pc1[0]=c1;
pc1[1]=0;
sscanf(pc1, "%d", &t1);
printf("c1=%x, t1=%x\n", c1, t1);
printf("c1=%d, t1=%d\n", c1, t1);
printf("c1=%c, t1=%c\n", c1, t1);
return 0;
}