0

Concept of arg c and arg v

arguments of main function

16th Jan 2018, 5:12 PM
Kumar Amresh
1 Odpowiedź
+ 4
In int main(int argc, char**argv) : The argc parameter of the main function stands for 'argument count', and represents the number of commands passed for compilation. Eg - g++ -o myexe myprog.cpp will be translated into an arg count of 4. The argv parameter of the main function is an array of strings and stands for 'argument vector'. It stores the passed commands inside its different elements, and also stores the path of the executable. Thus, printing argv[2] in this case prints 'myexe' to the screen.
17th Jan 2018, 1:35 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar