Jump to content
  • Advertisement
Sign in to follow this  
charpi

CMD with parameters

This topic is 2533 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

Ok, just a really simple question which I cant seem to get the answer from.

Just a very simple program, I'm using Visual Studio 2010, C++

//prog.exe
int age;
cin>>age;
cout<<"My age is "<<age<<endl;

Of course when I run it it is fine. However, what if I want to take the .exe, for example, and place it on the desktop and run it from there?

What I want:

C:/Desktop/prog 7
My age is 7

What I am getting:
C:/Desktop/prog 7
(I have to enter 7 here again)
My age is 7



Question: How do I make it that the parameter after the program is cin as the first variable?

Thank you guys.

Share this post


Link to post
Share on other sites
Advertisement
Sorry guys I just found the answer right after I posted it.

instead of

int main(){

return 0;
}

I need:

int main(int argc, char *argv){

}

for those who want to know

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!