Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Passing a parameter to C++ program
Name: stroke6463 Date: September 14, 2006 at 07:25:41 Pacific OS: XP Pro CPU/Ram: idk
Comment:
I want to have my program take a parameter from the command line and output a number. So when I am in the command line and type 'program.exe 4' my program will run its operations using 4 as the input and output the final value. Thanks for the help.
Name: StuartS Date: September 14, 2006 at 15:42:06 Pacific
Reply:
Look up the arg() function in the C++ documentation.
Stuart
0
Response Number 2
Name: tommycoolman Date: September 15, 2006 at 01:13:17 Pacific
Reply:
The main() function of your program would have to be modified to accept command line arguments.
#include
int main(int argc, char **argv) { printf("%s\n",argv[1]); return 0; }
"argc" is the number of command line arguments and argv is an array of strings that holds the arguments. The first argument is always the name of the program, so argv[1] would be the first argument.
0
Response Number 3
Name: stroke6463 Date: September 18, 2006 at 03:52:15 Pacific
Summary: I want to pass a parameter(this parameter determine pdf file location)to exe file(that convert pdf to text file)in my application in delphi. Please help me how can do this work? Thanks. Hamid reza ...
Summary: I am using this function below to execute a script that I wrote in C++. However, it is not running and not providing an error message. The system executing part of the statement runs (because I could ...