BinToHex

View Code
//************************************
// 函数: BinToHex
// 返回: void
// 作用: 2进制文件转16进制文件
//************************************
void BinToHex()
{
FILE *FpIn , *FpOut;
int c ;
FpIn=fopen("bin.txt","rb");
FpOut=fopen("Hex.txt","w");
if (NULL==FpIn)
{
printf("打不开bin.txt!\n");
goto EXIT;
}
if(NULL==FpOut)
{
printf("打不开hex.txt!\n");
goto EXIT;
}
while(true)
{
c=fgetc(FpIn);
if (EOF==c) goto EXIT;
fprintf(FpOut,"%02x ",c);
}

EXIT:
if(FpIn) fclose(FpIn);
if(FpOut) fclose(FpOut);
}

 
原文地址:https://www.cnblogs.com/guyan/p/2277676.html