# include <stdio.h>
/* Program bin2ascD reads binary file and saves every two bytes
 into ascii file as unsigned integers
 */

#define HEADER_LENGTH  10498


void main(int argc, char **argv)
{
	FILE *fpin, *fpout;
	unsigned int k;
	int c0, c1;

	if (argc != 3) {
	    printf("bin2ascD reads binary file and saves every two bytes\n");
	    printf("         into ascii file as unsigned integers\n");
		printf("Usage: bin2ascD  infile outfile\n");
		exit(1);
	}

	if( (fpin = fopen( argv[1], "rb" )) == NULL ) {
		printf("Could not open file %s \n", argv[1] );
		exit(1);
	}
	if( (fpout= fopen( argv[2], "w" )) == NULL ) {
		printf("Could not open file %s \n", argv[1] );
		exit(1);
	}


	fseek( fpin, HEADER_LENGTH, 0 ); /* skip the header */
	while ( ( c0 = getc(fpin) ) != EOF ) {
		c1 = getc(fpin);
		k = c0 + 256*c1;
		fprintf( fpout, "%4u\n", k);
	}

	fclose(fpin);
	fclose(fpout);
}

