int main (int argc, int argv). What does it means | SoloLearn: Learn to code for FREE!


int main (int argc, int argv). What does it means


8/5/2019 5:32:40 PM


7 Answers

New Answer


ibrohim What you have written is wrong. It should be int main(int argc, char *argv[]) or int main(int argc, char **argv) This is another form of main function in C/C++. This is used when you want to pass some data to your program when launching it from command line, script file or other programs. argc is the no of parameters passed to the main function and argv is an array of C style strings containing the actual arguments passed. So say your program name is myprog. Then if you launch your program from command line like myprog 1 2 3 then argc will equal to 4 meaning 4 parameters passed, this is because the first parameter is always the full path of the program including the name from where it was launched. So argv[0] = "full path of the program" argv[1] = 1 argv[2] = 2 argv[3] = 3


thank you


Here are some similar questions : but none of the answers in them seem as clear as ~ swim ~ 's one here.


it's the basis for command line argument...



Basically it is arg[ument]c[ounter] arg[ument]v[alues]