Can anyone tell me what are these two ** in front of Adj_matrix?

Each one designate a level of indirection (a pointer). So you can say that adj_matrix is a pointer to a pointer to int. My spidey sense says that adj_matrix is intended to be a dynamically allocated adjacency matrix, so you can do a google search for dynamic arrays in C++ for further details (or ask another specific question here).

i have these code which give values to adj_matrix from scanf value which give the user the choice to select the value.

printf("Enter the number of vertices\n");
    scanf("%d",&nv);
	
	/* allocate memory for the adjacency memory */
	adj_matrix = (int**)malloc(sizeof(int*) * nv);

How can i give the values programatically and not by user selection?.

>How can i give the values programatically and not by user selection?
That's even easier. Just replace scanf with an assignment to nv of whatever expression you want:

nv = 5;

/* allocate memory for the adjacency memory */
adj_matrix = (int**)malloc(sizeof(int*) * nv);

i have tried it already but i get an error
error: syntax error before "adj_matrix"

ok ok i found the error :). ths

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.