Click here to Skip to main content
15,891,726 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: STL string : is it any good? Pin
Mike Nordell15-Apr-02 11:02
Mike Nordell15-Apr-02 11:02 
GeneralUrgent help needed. enquire within Pin
15-Apr-02 5:59
suss15-Apr-02 5:59 
GeneralRe: Urgent help needed. enquire within Pin
Joaquín M López Muñoz15-Apr-02 6:35
Joaquín M López Muñoz15-Apr-02 6:35 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 6:40
suss15-Apr-02 6:40 
GeneralRe: Urgent help needed. enquire within Pin
Nish Nishant15-Apr-02 6:42
sitebuilderNish Nishant15-Apr-02 6:42 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 6:52
suss15-Apr-02 6:52 
GeneralRe: Urgent help needed. enquire within Pin
Nish Nishant15-Apr-02 7:00
sitebuilderNish Nishant15-Apr-02 7:00 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 7:12
suss15-Apr-02 7:12 
I don't get a prompt unless I runn it through the commandline, so at least I know the program works.

The main() routine supplied here has the job of checking for valid input and output files, opening them, and then calling the compression routine. It expects to find a compression routine in another module. If the files are not present, or no arguments are supplied, it prints out an error message, which includes the Usage string supplied by the compression module. All of the routines and strings needed by this routine are defined in the MAIN.H header file. I have included some explanations of the various modules further down.

I don't get a prompt unless I runn it through the commandline. This is part of my main program.

*/ This is the usage message
Usage:DOHUFF infile.txt outfile.txt
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bitio.h"
#include "errhand.h"
#include "main.h"


void usage_exit( char *prog_name );
void print_ratios( char *input, char *output );
long file_size( char *name );

int main( argc, argv )
int argc;
char *argv[];
{

BIT_FILE *output;
FILE *input;
setbuf( stdout, NULL );
if ( argc < 3 )

usage_exit( argv[ 0 ] );
input = fopen( argv[ 1 ], "rb" );

if ( input == NULL )
fatal_error( "Error opening %s for input\n", argv[ 1 ] );
output = OpenOutputBitFile( argv[ 2 ] );
if ( output == NULL )
fatal_error( "Error opening %s for output\n", argv[ 2 ] );
printf( "\nCompressing %s to %s\n", argv[ 1 ], argv[ 2 ] );
printf( "Using %s\n", CompressionName );
CompressFile( input, output, argc - 3, argv + 3 );
CloseOutputBitFile( output );
fclose( input );

print_ratios( argv[ 1 ], argv[ 2 ] );
return( 0 );

}
/*
* This routine just wants to print out the usage message that is
* called for when the program is run with no parameters. The first
* part of the Usage statement is supposed to be just the program
* name. argv[ 0 ] generally holds the fully qualified path name
* of the program being run.
*/

void usage_exit( prog_name )
char *prog_name;

{

char *short_name;
char *extension;
short_name = strrchr( prog_name, '\\' );
if ( short_name == NULL )
short_name = strrchr( prog_name, '/' );
if ( short_name == NULL )
short_name = strrchr( prog_name, ':' );
if ( short_name != NULL )
short_name++;
else

short_name = prog_name;
extension = strrchr( short_name, '.' );
if ( extension != NULL )
*extension = '\0';

printf( "\nUsage: %s %s\n", short_name, Usage );
exit( 0 );

}
GeneralRe: Urgent help needed. enquire within Pin
Nish Nishant15-Apr-02 7:23
sitebuilderNish Nishant15-Apr-02 7:23 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 7:35
suss15-Apr-02 7:35 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 22:39
suss15-Apr-02 22:39 
GeneralRe: Urgent help needed. enquire within Pin
Nish Nishant15-Apr-02 6:41
sitebuilderNish Nishant15-Apr-02 6:41 
GeneralRe: Urgent help needed. enquire within Pin
Christian Graus15-Apr-02 22:55
protectorChristian Graus15-Apr-02 22:55 
GeneralRe: Urgent help needed. enquire within Pin
15-Apr-02 23:37
suss15-Apr-02 23:37 
GeneralRe: Urgent help needed. enquire within Pin
Christian Graus16-Apr-02 1:51
protectorChristian Graus16-Apr-02 1:51 
Generallink to raw binary. Pin
Hyien15-Apr-02 5:51
Hyien15-Apr-02 5:51 
GeneralRe: link to raw binary. Pin
Mike Nordell15-Apr-02 5:54
Mike Nordell15-Apr-02 5:54 
QuestionHow to run UNIX command from VC++? Pin
Ravi Shankar15-Apr-02 5:02
Ravi Shankar15-Apr-02 5:02 
AnswerRe: How to run UNIX command from VC++? Pin
Tim Deveaux15-Apr-02 5:56
Tim Deveaux15-Apr-02 5:56 
GeneralDispay Lines in Window Pin
15-Apr-02 4:43
suss15-Apr-02 4:43 
GeneralRe: Dispay Lines in Window Pin
Niklas L15-Apr-02 4:57
Niklas L15-Apr-02 4:57 
GeneralRe: Dispay Lines in Window Pin
15-Apr-02 7:00
suss15-Apr-02 7:00 
GeneralRe: Dispay Lines in Window Pin
Niklas L16-Apr-02 3:55
Niklas L16-Apr-02 3:55 
GeneralDisable property page switching Pin
15-Apr-02 4:40
suss15-Apr-02 4:40 
GeneralProblem with maximizing and minimizing window Pin
Leodsk15-Apr-02 3:57
Leodsk15-Apr-02 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.