-1

I want to use parameters in a program I made in C/C++ languages. Example:

MaxPayne2.exe -developer -developerkeys

I want to use a parameter like this in my exe file. How can I do it?

9AspecT
  • 11
  • 4

1 Answers1

0

https://en.cppreference.com/w/cpp/language/main_function

While I would usually recommend adding more context this is your answer.

The standard c++ main has two additional parameters,

int main (int argc, char *argv[]) { }

To use these "arguments" (as they are called) you just reference their point in the argv array.

argc = the number of additional arguments supplied.

argv = the array of argument values supplied.

Example:

int main (int argc, char *argv[]) 
{
 cout << argv[argc-1]; //Prints out the last argument supplied.
}

(note)If my syntax is wrong someone please correct me, my c++ is a bit rusty.

Mindstormer
  • 299
  • 3
  • 16