what is the meaning of the int main(int nNumberofArgs, char* pszArgs[]) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the meaning of the int main(int nNumberofArgs, char* pszArgs[])

And also I want to ask Can we declare variables before int main()?

25th Jun 2018, 6:26 AM
Lucky
Lucky - avatar
1 Answer
+ 1
int args and char argv[] are used for detecting command line arguements eg. ./a.out first_arg second_arg here, int args detects, no. of arguements, in our case, its 3 (including ./a.out) char argv stores the arguement in our case, argv[0] = a.out argv[1] = first_arg argv[2] = second_arg and yes variables can be declare outside/before main function, they are called global variables
25th Jun 2018, 6:45 AM
‎ ‏‏‎Anonymous Guy