回复 楼主 原来一如当初
可如此如此......建一个"in.txt"文件夹,把数据输入进去即可。
#include<stdio.h>
#include<string.h>
#define size 20
void main()
{ int to_int(char * p);
FILE *f;
FILE *k;
char p[size],a[2];
int i=0,t;
if((f=fopen("in.txt","r"))==NULL)
{ printf("can't open the file!");
return;
}
while(fgets(p,size,f)!=NULL)
{ i++;
t=to_int(p);
k= fopen( "out.txt","a");
if( k!= NULL )
fprintf(k,"%x\n",t);
fprintf( k,"%02X\n%02X\n%02X\n%02X\n"
, (unsigned)((t>>24)&0xFF)
, (unsigned)((t>>16)&0xFF)
, (unsigned)((t>> 8)&0xFF)
, (unsigned)((t>> 0)&0xFF),t);
fclose(k);
}
fclose(f);
}
int to_int(char * p)
{
int n;
int i;
int count=0;
for(i = count = 0; p[i]; i++)
count = count * 10 + (p[i] - '0');
return count;
}