1

The main function goes like this:

void main( int argc, char** argv ){
    // validate that an input was specified
    if( argc != 2 )
    {
        printUsage();
        return;
    }

    if( !strcmp(argv[1], "train") ) learn();
    else if( !strcmp(argv[1], "test") ) recognize();
    else
    {
        printf("Unknown command: %s\n", argv[1]);
        printUsage();
    }
}

When I execute the program the console disappears as soon as it appears.

Thanks so much for your patience and help! :)

Nil

allissaid
  • 15
  • 4

4 Answers4

5

Why doesn't my console wait for an input in VS2010 and Windows7?

Because you don't instruct it to wait for input.

Try system("pause"); or getchar() or something like that.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
2

This program doesn't use user input, but uses program arguments.

This program need 1 input argument that you can set that in these ways:

  1. open cmd, change directory(cd) to the where the exe file exists, and run the program with arguments. e.g. main.exe train
  2. on vs2010, go to project properties, under "Configuration Properties" find Debugging and set the "Command Arguments" to what argument you want.
quamrana
  • 37,849
  • 12
  • 53
  • 71
hamed
  • 597
  • 4
  • 15
0

You can just hit 'Ctrl+F5' and by default will wait for you to hit enter in order to close the console rather than adding code such as 'pause', getchar() or similar. See this SO post: Preventing console window from closing on Visual Studio C/C++ Console application

Community
  • 1
  • 1
EdChum
  • 376,765
  • 198
  • 813
  • 562
0

By debugging (press F5) the console app, VS won't call 'pause' automatically after your app finishes. You can RUN (press CTRL+F5) the app, and VS would call 'pause' for you.

Rango
  • 1,087
  • 7
  • 5