argc and argv confusion
Hope that someone can help clarify my confusion with the above fn parameters.
In a text I'm reading, the following is stated: "The argc argument is an int that indicates the number of arguments, and the argv argument is an array of char pointers." A code example follow to illustrate this point: Code:
#include <stdio.h> Hope that someone can understand the basis of my confusion, and help me understand this aspect of C programming |
I think your confusion is being caused because they swap the arguments around when they pass them to showArguments.
|
Is it only in Main() that argc and argv are specified in the way mentioned? I have tried to switch the order of arguments in ShowArguments(), but that does not compile.
|
Yes it is only in main they are that way around -- in any other function/method the person writing the code is at liberty to assign the arguments they wish in the order they wish but main is a special case and only accepts specific arguments in a specific order.
I think the person who wrote the code you are looking at may have been trying to tell the reader that the order of arguments isn't relevant outside of main but caused confusion in the process. |
Quote:
How about a clearer program... Code:
#include <stdio.h> |
All times are GMT -5. The time now is 04:56 PM. |