Help needed ! !!

what is command line argument ?
( int main(int argc,char* argv[]) )

what is the use of command line argument?
geeksforgeeks says “They are used to control program from outside instead of hard coding those values inside the code.”

what does this mean?

please elaborate.

one more question :
in line 4 why are they taking functions argument as type int ** ?
please explain.

@prateek_5,
just like another function “main” is a function too, right? Thus, we can pass arguments to this function when we call it. And who calls the main function…??..the terminal which executes the program. So, if we have any need to change the behaviour of our program on runtime, we can use command line arguments.

E.g.
Program(A.cc):

int main(int argh, char const *argv[]){
cout<<argv[1];
return 0;
}

Run in terminal:
./A.out 1

what is the use of this?

@prateek_5,
You can use it anyway you want. One use that I personally do it for is generating random test cases. I can control the value of seed of random function by providing command line arguments.
You will know it’s use when you would have a necessity of using it. Till then, just cram it up for semester exams. Its not that important for now.

please look at second question (one with screenshot attached)

@prateek_5,
It is pointing to a 2d array, so it is a pointer of a pointer.

i didn’t understand. I mean why is it called pointer to pointer?

@prateek_5,
You will when you will learn about pointers in C++.

I did but there was no reference to 2D array there.

@prateek_5 hey ,we can create an array of pointers also dynamically using a double pointer. Once we have an array pointers allocated dynamically, we can dynamically allocate memory and for every row.
#include <stdio.h>
#include <stdlib.h>

int main()
{
int r = 3, c = 4, i, j, count;

int **arr = (int **)malloc(r * sizeof(int *)); 
for (i=0; i<r; i++) 
     arr[i] = (int *)malloc(c * sizeof(int)); 

// Note that arr[i][j] is same as *(*(arr+i)+j) 
count = 0; 
for (i = 0; i <  r; i++) 
  for (j = 0; j < c; j++) 
     arr[i][j] = ++count;  // OR *(*(arr+i)+j) = ++count 

for (i = 0; i <  r; i++) 
  for (j = 0; j < c; j++) 
     printf("%d ", arr[i][j]); 

/* Code for further processing and free the
dynamically allocated memory */

return 0;
}
Output:

1 2 3 4 5 6 7 8 9 10 11 12

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.