main parameters.........
-
Hey guys, I was wondering when we use these parameters (int argc, char *argv[]) in a main function? I have no clue why they use it.... Thanks in advance
void main (int argc, char *argv[]) { .......... ......... }
They are used for command line parameters. argc tells you how many elements are in the argv array. argv holds the space-delimited strings. Say you write a program that will write out a given string X number of times and you want to allow the user to determine what the string is and how many times by passing in command line parameters:
MyEcho.exe 5 Hello!
argc would be 3 (1 for the module name, and then the parameters). argv would hold the parameters to parse for the program.If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Hey guys, I was wondering when we use these parameters (int argc, char *argv[]) in a main function? I have no clue why they use it.... Thanks in advance
void main (int argc, char *argv[]) { .......... ......... }
For command line arguments. Basically, if you have an executable named "app.exe" and you a the command line like this: app.exe your_arg1 your_arg2 then argc is 3, argv[1] is "your_arg1" and argv[2] is "your_arg2". Note that argv[0] is always "app.exe".
Best, Jun
-
Hey guys, I was wondering when we use these parameters (int argc, char *argv[]) in a main function? I have no clue why they use it.... Thanks in advance
void main (int argc, char *argv[]) { .......... ......... }
See here.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb