Hillbillie i modified ur code but it doesn't work, here is the code thnx. All the output file contains is many many "1, "s......
Code:
/* Takes a binary file and output its hex equivalent in a text file */
#include <stdio.h>
int main( int argc, char *argv[] )
{
FILE *fpBinary, *fpHex;
unsigned short int c;
if ( argc == 1 ) {
printf( "%s\n\n%s\n%s\n\n\n", "Usage: bin2hex.exe < filename >",
"It takes a binary file and output its hexidecimal equivalent",
"in a text file ( hex.txt ) in the current directory." );
system( "PAUSE" );
return 0;
}
if ( ( fpBinary = fopen( argv[ 1 ], "rb" ) ) != NULL ) {
if ( ( fpHex = fopen( "hex.txt", "w" ) ) != NULL ) {
while ( c = fgetc( fpBinary ) != EOF ) {
fprintf( fpHex, "%x, ", c );
}
}
else
printf( "\aError\n\n" );
}
else
printf( "\aError\n\n" );
system("PAUSE");
return 0;
}