101 Question: Passing Numeric Command-Line Arguments

Oct 21, 2009 at 5:56am
I read a book, there is a small program which add 2 numbers.

The "add" program begins from
int main(int argc, char *argv[])

In the command line input
C> add 100.2 232


My question is both 2 values are converted by using atof(argv[1]) & atof(argv[2]), where does argc goes?? what does the function of argc?


Oct 21, 2009 at 6:01am
argc is the number of arguments. It is the program name plus the number of arguments, in your case 2. So your argc will contain the number 3.
Topic archived. No new replies allowed.