Advertisement Jump to content
Sign in to follow this  
sriniatig

executable with parameters

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I've made a program which takes in 2 filenames and then converts it into a 3rd file. What I want is to have this process as a executable parameter. Example: convert.exe <parameters> filename1 filename2 target_filename Could someone guide me to write this.... Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
The main function recieves an array of strings with command line arguments, you'll have to parse them manually. Also beware that the first argument is the executable's name and not an actual parameter.
int main(int argc, char **argv) {
if(argc < 4) {
printf("syntax: %s {filename1} {filename2} {target_filename}\n", argv[0]);
return 1;
}

const char *fn1 = argv[1];
const char *fn2 = argv[2];
const char *target = argv[3];

// etc..
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!