View Full Version : DOS help, I guess.
I have a program I want to run and automatically enter an input for. How do I do that from the command line?
I have a program called 80initparse.exe that needs to take an input string (contained in a variable). So I do 80initparse.exe to run the program. But how do I get it to take that extra input?
Shoeberto
04-28-2005, 03:24 AM
Are you programming something? If it's in C++, then you'd want something like this:
#include <iostream>
using namespace std;
int main() {
string myinput;
cout << "Input: ";
cin >> myinput;
return 0;
}
I'm not exactly sure what you're asking. If it's how to run a program from the command prompt, you just change to the directory it's in using cd [directory name] and then type in the name of your program.
Samuraid
04-28-2005, 03:35 AM
If you want to pass switches directly in, like: (I apologize if this is totally redundant and you already know this)
80initparse.exe switch1 switch2
...just grab the arguments off main().
int main(int argc, char **argv)
argc contains the number of arguments passed into the program from the command line.
argv is an array containing the arguments placed in the command line.
Note: argv[0] contains the name of the program (in this case 80initparse.exe) and the arguments start at argv[1]
Depending on your DOS shell, if it supports the pipe (|), use that : ).
If you want to pass switches directly in, like: (I apologize if this is totally redundant and you already know this)
80initparse.exe switch1 switch2
...just grab the arguments off main().
int main(int argc, char **argv)
argc contains the number of arguments passed into the program from the command line.
argv is an array containing the arguments placed in the command line.
Note: argv[0] contains the name of the program (in this case 80initparse.exe) and the arguments start at argv[1]
You have no idea how helpful that was. Thanks a bunch! :)
For lurkers, instead of using "char **argv", I used "char *argv[]", with no difference.
Samuraid
04-28-2005, 08:48 PM
Ya, either one should work. :) I just couldn't remember the exact syntax at the moment so I just copied and pasted that line from some C++ I had written a while ago.
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.