Jump to content
  • Advertisement
Sign in to follow this  
sriniatig

executable with parameters

This topic is 4816 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!