I have a small code to look whats the argv
's
#include <iostream>
using namespace std;
int main(int argc, char** argv){
cout << "===================" << endl;
cout << "argc: " << argc << endl << endl;
cout << "argv[0]: " << argv[0] << endl << endl;
cout << "argv[1]: " << argv[1] << endl << endl;
//cout << "argv[2]: " << argv[2] << endl << endl; //Program crash
cout << "===================" << endl;
return 0;
}
When I start the program with no parameters:
argc
is 1
argv[0]
is the execution path
argv[1]
should be out of range and the program should crash, but the program terminates like I write return
. If I check the errorlevel it is 9009
If I try to access argv[2]
the program crashs as expected
(When I start the program with one parameter everything works fine)
Why it doesn't crash like argv[2]
when I access argv[1]
?
And for what stand errorlevel 9009?
Thanks in advance