But why would you want to enter this command c:\myprog.exe argument1 argument2 in the Windows CMD. Please give me an example. I understand what you are saying, I just don't understand the purpose of it.
so I've written this short program below. Does this mean now I can open up the command prompt and type in the program's name and maybe 5 and 6 as arguments and the program will run?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main(int argc, char *argv)
int x, y;
x = static_cast<int> (*argv);
y = static_cast<int> (*argv);
cout << x <<" Multiplied by "<< y <<" is equal to " << x*y <<endl <<endl;
cout << "Press the enter key to continue ...";
I think I understand now. One last question: in the CMD prompt, do you have to specify the path to your .exe or can you just enter the name of your .exe without specifying the path as you would do with "ping" and "ipconfig"?
It depends. If you're in the directory of your exe, you don't need to specify the path.
Furthermore, there's an environment variable named PATH, which can be altered. When you run a command, any directories listed in the PATH variable will be searched to see if the command/exe you're trying to run exists in any of them.
You can see what's currently in there by typing echo %PATH% in the command prompt.
The easiest way to add something to the path is to do so in the Environment Variables... section of the advanced system settings. If you add a directory to the path, you won't need to explicitly type the path when trying to run a program stored within it.