[galib] benifit of argc and argv to main() ?
Liekens, A.M.L.
A.M.L.Liekens at tue.nl
Tue Dec 28 12:00:23 EST 2004
I'm sorry to be bold in my reply, but do you have any experience with C++?
int argc is the number of arguments given on the command line to the executable, and char** argv is the array containing the commands themselves. In the examples of galib, you can give a seed for the random number generator as a parameter when executing the example, i.e. by running
./ex1 seed 5
thus affecting the behavior of the GA by seeding it (the strcmp() recognizes the parameter "seed" and the atoi() converges the "5" to an int).
You won't really see anything different, indeed, if you don't pass a seed parameter to the executable, and remove the parts of the code that interpretes these parameters, duh.
There is consequently, some usefulness in those parts of the code.
Anthony,-
-----Original Message-----
From: galib-bounces at mit.edu on behalf of Essam Almasri
Sent: Tue 12/28/04 15:45
To: galib at mit.edu
Cc:
Subject: [galib] benifit of argc and argv to main() ?
Dear Sir/ Madam
Does it make difference to define:
int main(argc, **argv) or int main().
what is the use of this part which I see in all examples:
for(int ii=1; ii<argc; ii++) {
if(strcmp(argv[ii++],"seed") == 0) {
seed = atoi(argv[ii]);
}
}
I have tried to run the examples without that parts and it works. Am I wrong.
Regards
---------------------------------
Do you Yahoo!?
Dress up your holiday email, Hollywood style. Learn more.
More information about the galib
mailing list