What does these lines means?

int main(int nNumberofArgs, char* pszArgs[]) int main(int argc, char *argv[]) for(;;) int anything(void)

I'm really sorry if this has been posted or explained
I'm new to C++

Please forgive me
Last edited on
As described in the book I am studying from, the second line means:

The argc parameter is an integer that holds the number of arguments on the command line. It will always be at least 1, because the name of the program qualifies as the first argument

The argv parameter is a pointer to an array of character pointers. Each pointer in the argv array points to a string containing a command-line argument. The programs name is pointed to by argv[o]; argv[1] will point to the first argument etc.


The first line just looks like a variation of the second; you dont have to have
(int argc, char *argv[]) but most people do because its more easily read by others.

for(;;) is just an infinite for loop. There is no initialization expression, or increment therfore no variable or whatever could break the loop.

No idea what the bottom one is :S
The first two lines have the same meaning (argc and argv are the standard names) they allow your program taking arguments
eg:
if you call your program this way on command line:
myprogram argument1 argument2

then


Variable Value
argc | 3
argv[0] | "yourprpgrampath\\yourprogramfilename"
argv[1] | "argument1"
argv[2] | "argument2"


for(;;) is an infinite loop ( http://www.cplusplus.com/forum/articles/7034/ )

int anything(void) is the same as int anything(void), so anything would take no arguments

EDIT: too slow...
Last edited on
int anything(void)

That is the C-version of

int anything()

Explicitly using void is usually uncommon but it can be used.
Topic archived. No new replies allowed.