예제 #1
0
void CharCount(char *argv)
{
	int i, sum=0;
	unsigned long byte;
	BIT_FILE *input_file;
	//get pointers of the input file and output file by argument from command line
	input_file = OpenInputBitFile(argv);

	//initialize symboy counter array symbo[NUM]
	memset(symbol, 0, sizeof(int)*NUM);
	while (1) {
		byte = InputBits(input_file, 8);
        symbol[byte]++;		
		if (byte == 256) {
			break;
		}
	}
    for (i=0; i<NUM; i++) {
		sum += symbol[i];
	}
	printf("total weight: %d\n", sum);
}
예제 #2
0
int main(int argc, char *argv[])
{
	FILE *output;
	BIT_FILE *input;

	setbuf( stdout, NULL );
	if ( argc < 3 )
		usage_exit( argv[ 0 ] );
	input = OpenInputBitFile( argv[ 1 ] );
	if ( input == NULL )
		fatal_error( "Error opening %s for input\n", argv[ 1 ]);
	output = fopen( argv[ 2 ], "wb" );
	if ( output == NULL )
		fatal_error( "Error opening %s for output\n", argv[ 2 ]);
	printf( "\nExpanding %s to %s\n", argv[ 1 ], argv[ 2 ] );
	printf( "Using %s\n", CompressionName );
	argc -= 3;
	argv += 3;
	ExpandFile( input, output, argc, argv );
	CloseInputBitFile( input );
	fclose( output );
	putc( '\n', stdout );
	return( 0 );
}