What dose int main(int argc, char ** argv) mean? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 8

What dose int main(int argc, char ** argv) mean?

what dose it do?

10th Sep 2018, 4:17 PM
LONGTIE👔
LONGTIE👔 - avatar
5 Réponses
+ 6
it takes an integer argument and a pointer to a char array, sometimes you use double pointers to point to a multi dim array, atleast that is how i have seen it used. but i could be wrong, i havent seen it used within a main function LONGTIE👔 so argv is an array of pointers to characters and argc is the number of elements within the array of pointers
10th Sep 2018, 4:22 PM
Robert Atkins
Robert Atkins - avatar
+ 7
Ok, thank you for clearing that up. @Robert Atkins, hmmm... you cant metion ppl on the computer site... weird
10th Sep 2018, 4:31 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 7
int argc is count of number of arguments provided through command line arguments and char **argv is 2 dimensional array of real arguments provided through command line.
10th Sep 2018, 5:58 PM
#DARK_PROGRAMMER_✔
#DARK_PROGRAMMER_✔ - avatar
+ 2
Your program are always executed by command line. Program, that runs your program, provides array of strings as an launch parameters. For example it could be a file names to work with. The result of your program should be returned as an integer number in the result of the main function. That number could be checked by parent program. For example you can use shell script to pass arguments to your program and check it's result.
10th Sep 2018, 6:46 PM
Sergey Ushakov
Sergey Ushakov - avatar