7/22/2009

Show the progress of data processing

cout << flush;
cout.flush();
cout << endl;

*Forcing all buffered output to actually be printed is known as "flushing" the stream. A flush can be forced by calling the flush function associated with each output stream, inserting the magic variable flush into the stream, or inserting endl.



7/20/2009

Argc and Argv

argc stands for Argument Count. This variable contains the number of arguments passed into the application.
argv stands for Argument Values. This is an array of strings which contains the values passed into the application. argv[0] is always the name of the application.

What they basically do is allow you to use the command line parameters passed to your application. Even if you declare them in main(), you are not forced to use them, however some compilers might give you a warning for "unused variable."
example:

$ ./foo bar bletch

argc will have the value 3 (there are three elements on the command
line), and argv will contain the following:

argv[0] = "./foo"
argv[1] = "bar"
argv[2] = "bletch"