[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppArgv
The array of arguments contains the filename of the program itself at index 0 and then the parameters the user gave when starting the executable.
The size of this array is argc.
Below is an example showing all parameters a user entered.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppArgv
(C++) argv
With argc the arguments of the main function. It stands for array of arguments.The array of arguments contains the filename of the program itself at index 0 and then the parameters the user gave when starting the executable.
The size of this array is argc.
Below is an example showing all parameters a user entered.
This means if you start the program with e.g.int main(int argc, char* argv[]) { for(int i=0; i<argc; ++i) { std::cout << i << " : " << argv[i] << std::endl; } return 0; }
- include <iostream>
testMain Hello WorldYour output will be something like:
0 : testMain 1 : Hello 2 : World
'argv' links
Code links
- #include
- scope operator, ::
- stream out operator, <<
- char
- cout
- endl
- #include
- iostream
- int
- main
- return
- std
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
