Sign in to follow this  
charpi

CMD with parameters

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this