?? asciitohex.cpp
字號:
#include "stdio.h"
unsigned hexdata;
char *s, m[20];
void main()
{
FILE *fp,*outfp1,outfp2; /*定義一個文件指針*/
int i;
unsigned char c1[2]={0},c2[2]={0};
fp=fopen("ledxf.hex", "rt"); /*打開當(dāng)前目錄名為time0.hex文件*/
outfp1=fopen("out2.dat", "a+"); /*創(chuàng)建一個文件并增加*/
if(fp==NULL) /*判斷文件是否打開成功*/
puts("File open error");/*提示打開不成功*/
for(i=0;i<2000;i++)
{
fscanf(fp,"%s %s",c1,c2);
fprintf(outfp1, "0x%s%s\n", c1,c2); /*向所建文件寫一整型數(shù)*/
if(c1[0]<0x40&&c1[0]>=0x30)c1[0]=c1[0]-0x30;
else c1[0]=c1[0]-0x37;
if(c1[1]<0x40&&c1[1]>=0x30)c1[1]=c1[1]-0x30;
else c1[1]=c1[1]-0x37;
if(c2[0]<0x40&&c2[0]>=0x30)c2[0]=c2[0]-0x30;
else c2[0]=c2[0]-0x37;
if(c2[1]<0x40&&c2[1]>=0x30)c2[1]=c2[1]-0x30;
else c2[1]=c2[1]-0x37;
hexdata=(unsigned int)( (unsigned int)c1[0]*4096+(unsigned int)c1[1]*256+
(unsigned int)c2[0]*16+(unsigned int)c2[1]);
// fprintf(outfp1, "%d,\n", hexdata); /*向所建文件寫一整型數(shù)*/
}
i=fclose(fp); /*關(guān)閉打開的文件*/
i=fclose(outfp1);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -