Wow, miss a few weeks...
Umz
I don't know if you noticed what caused the problem, but
cin.ignore(...)
only works if your input stream is completely read and waiting for the user to type something. After using
cin >> foo;
that is not the case. Try
thecoolguy98's method and see if that helps:
1 2 3 4 5 6
|
void pause()
{
cout << "Press ENTER to continue...";
cin.sync();
cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
}
|
chu121su12
Don't worry so much about all the TCHAR and PROCESS_INFORMATION and the like --it's all Windows boiler-plate.
The
main() functions arguments are
int argc
The number of c-strings in the
argv array
char* argv[]
Each piece of the command-line that invoked your program.
The first item (index 0) is the name of your program.
The second item (index 1) is the first argument to your program.
Etc.
Try playing around with it:
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
using namespace std;
int main( int argc, char* argv[] )
{
cout << "arguments:\n";
for (int cntr = 0; cntr < argc; cntr++)
cout << cntr << ": " << argv[ cntr ] << '\n';
return 0;
}
|
The program name is also considered an 'argument' because it is part of the command used to invoke your program. Try running your program from different directories to see how it affects argv[0].
D:\prog\cc\foo\args> a.exe one two three
arguments:
0: a.exe
1: one
2: two
3: three
D:\prog\cc\foo\args> a Hello world!
arguments:
0: a
1: Hello
2: world!
D:\prog\cc\foo\args> cd ..
D:\prog\cc\foo> args\a "John Jacob Jingleheimer Schmidt"
arguments:
0: args\a
1: John Jacob Jingleheimer Schmidt
When you are done playing with the command-line, try double-clicking the executable from Explorer (or from the window manager if you are using Linux or Mac).
[edit] Oh, you'll have to add that pause function and use
pause();
before
return 0;
before you try it from your WM. heh.[/edit]
Hope this helps.
[edit] Added "using namespace std" to the example. (Sorry I forgot that last time.) [/edit]