|
[Sponsors] |
April 13, 2014, 11:24 |
interesting and mysterious "argc" "argv"
|
#1 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 12 |
hi !
we often see the code : Code:
int main(int argc, char *argv[]) argc is an integer showing the number of parameters that your program was called with. argv is an array of strings (double pointer of chars) containing the actual parameters. but I want to know where the declaration of variables "int argc, char *argv[]" are in source code ? I want to have a look at them could you help me? |
|
April 13, 2014, 14:11 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128 |
Quick answer:
|
|
April 13, 2014, 22:14 |
|
#3 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 12 |
thank you ! I will careful read them .
|
|
April 13, 2014, 23:26 |
|
#4 | |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 12 |
Quote:
I have saw the code : Code:
00001 // 00002 // setRootCase.H 00003 // ~~~~~~~~~~~~~ 00004 00005 Foam::argList args(argc, argv); 00006 if (!args.checkRootCase()) 00007 { 00008 Foam::FatalError.exit(); 00009 } And when we use the variables "argc, argv" to construct the object "args" , we must declare "argc, argv" in advance ! Then I wonder where are they declared ? thanks! xuhe |
||
April 14, 2014, 03:42 |
|
#5 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
That is some default C(++) behavior.
See for example http://stackoverflow.com/questions/3...char-argv-mean |
|
April 14, 2014, 05:21 |
|
#6 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 12 |
thank you very much !
|
|
Tags |
mysterious |
Thread Tools | Search this Thread |
Display Modes | |
|
|