This question has already been answered:
- How argc and argv work 3 answers
int main(int argc, char *argv[]) What is the meaning of the specified function arguments?
This question has already been answered:
int main(int argc, char *argv[]) What is the meaning of the specified function arguments?
The general meaning of the arguments is to set the program arguments via the command line when the program is started.
In this ad
int main(int argc, char *argv[]) the argc parameter specifies the total number of arguments passed to the program when it is started, and the argv array specifies pointers to string representations of the arguments. If argc not equal to 0, then argv[0] specifies either the name of the program being run, or, if the environment does not pass the name of the program to the program, then the empty string "" . The value of argv[argc] always 0.
You can use any names instead of argc and argv at your discretion.
You can print the arguments passed to your program in various ways. For example,
#include <iostream> int main( int argc, char * argv[] ) { for ( char **p = argv; *p; ++p ) std::cout << *p << std::endl; } If your program does not need any arguments passed to it at startup, then you can declare the main function as
int main() argc is the number of elements in the argv array.
argv is an array of parameter strings passed on the command line.
prog.exe first second third agrv[0] - имя файла prog.exe argv[1] - first argv[2] - second argv[3] - third Some operating systems (and the programs themselves) can process the parameters — for example, by combining what is in quotes into one parameter, or replacing a pattern of type * with a list of file names that matches the pattern, but that is another question ...
spawn... to transmit some sort of nonsense, and that is just nonsense, and not a null pointer - otherwise spawn... frayed (VC ++, the same Open Watcom will still pass the correct name not to enter as argv[0] ). But, since you wrote - “far from always” - then where is this found in the real, so to speak, world, and not in the code specially created for this? - HarryCreateProcess and transfer any nonsense to lpCommandLine . - VladDargv[0] value for all sorts of security related things. For example, by program name, look for the name of the file with the settings. - VladDSource: https://ru.stackoverflow.com/questions/631404/
All Articles
mainfunction is needed” will appear soon. - αλεχολυτ