汉字与十六进制互转,输入1汉字转十六进制,输入2十六进制转汉字weixin_53569144ZIP汉字与十六进制互转.zip 47.48KB 立即下载资源文件列表:ZIP 汉字与十六进制互转.zip 大约有10个文件 main.c 1.08KB main.o 1.65KB Makefile.win 1.16KB 转换.dev 939B 转换.exe 132.13KB 转换.ico 2.19KB 转换.layout 93B 转换_private.h 583B 转换_private.rc 91B 转换_private.res 2.45KB 资源介绍: 工程可在dev软件中打开,压缩包中带有exe文件,可在window下直接执行 #include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ #define MAX_NUM 100 int main() { unsigned char hanzi[MAX_NUM] = {0}; unsigned char hex[MAX_NUM] = {0};//0xB0,0xAE,0xCE,0xD2,0xD6,0xD0,0xBB,0xAA int i = 0; int flag; do { printf("汉字转十六进制输入1\n十六进制转汉字输入2\n请输入:"); scanf("%d",&flag); if(flag == 1) { printf("请输入汉字:"); scanf("%s",&hanzi); printf("输入汉字的十六进制为:"); for (i = 0; i < MAX_NUM; i++) { if(hanzi[i] == '\0') { break; } printf("%02X ",hanzi[i]); } printf("\n"); } else if(flag == 2) { printf("请输入十六进制的数:"); while (getchar() != '\n') { ; } i = 0; do{ scanf("%x",&hex[i]); i++; if(i >= MAX_NUM) { break; } }while(getchar()!='\n');//遇到换行时结束循环 printf("输入十六进制的汉字为:"); printf("%s\n",hex); } else { printf("输入错误,请重新输入1或2!!!\n"); } }while(1); return 0; }