CMD with parameters

Started by
0 comments, last by charpi 12 years, 8 months ago
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.
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

This topic is closed to new replies.

Advertisement