hi could anyone please tell me in detail about the parameters to the main function argc and argv.please let me know as much as possible.
int main(int argc, char *argv)
You can name them whatever you want, but these are the normal names.
argc is non-negative. It gives the number of useful elements in argv.
If argc is positive, argv contains the program name. Then argv through argv[argc - 1] point to character arrays that contain the program's command line arguments.
For example, if I run a program at the command line, such as
argc will equal 2; and argv will compare equal to "unzip"; and argv will compare equal to "filename.zip".
When I open up a BASH shell and run perl -e 'print "Hello, world!\n"', perl gets an argc of 3, with argv pointing to "perl", argv pointing to "-e", and argv pointing to the string containing
print "Hello, world!\n"
(to represent that string in C syntax, that would be "print \"Hello, world!\\n\"")
Different command line shells use different ways of quoting arguments -- most separate arguments by spaces, with either single or double quotes used to allow arguments with spaces, as seen in the perl example -- this is all invisible to the program, though. In Windows I'd have to write, perl -e "print \"Hello, world!\n\""