[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
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.
  1. include <iostream>
int main(int argc, char* argv[]) { for(int i=0; i<argc; ++i) { std::cout << i << " : " << argv[i] << std::endl; } return 0; }
This means if you start the program with e.g.
testMain Hello World
Your output will be something like:
0 : testMain
1 : Hello
2 : World


'argv' links

Code links



last edited (November 5, 2006) by bilderbikkel, Number of views: 2970, Current Rev: 5 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.