Originally Posted by
Finchie_88
I usually use Dev-C++. I've tried this code in Dev-c++, and it works, but I then tried it in Visual C++ and all I got was a program that crashed when it ran. Here is the code.
[
Did you give any command-line arguments?
Maybe you could try something like this to see what's happening:
Code:
int main(int argc, char* argv[])
{
cout << "argc = " << argc << endl;
if (argc > 1) {
cout << "argv[1] : " << argv[1] << endl;
}
return 0;
}
In any case, you shouldn't use argv[x] unless you know that argv[x] is defined.
Programs should never be written in a way that invalid user input can cause a crash.
Regards,
Dave