View Full Version : can anyone plz.. explain
ramakrishna
08-08-2005, 01:09 PM
can anyone explain what is the use of the arguments in the main function?
int main(int argc, char * argv[])
i3839
08-08-2005, 01:23 PM
Imagine that your program is named myapp. If that program is executed as "myapp opt1 opt2" then argc = 3, argv[0] = "myapp", argv[1] = "opt1" and argv[2] = "opt2". argv[0] can also be the full path to the program, e.g. /usr/bin/myapp, depending on which OS you run it on. It's used to pass commandline options to programs.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.