Message from C, C++ discussions

December 2019

— Didn't think that way


Graph.c|62 col 19 warning| assignment to ‘int **’ from ‘long unsigned int’ makes pointer from integer without a cast [-Wint-conversion] [c/gcc]

— It might be a good solution to have a linear array with size N*N and compute the address with col + row * noCols

Message permanent page

— What is noCols?

— The number of columns, or in your case graph->N

— Oh ok

— So I can do like this right?

graph->matrix = (int **)malloc(sizeof(graph->N * graph->N))

— int * - pointer to int

— Wait I'll send struct also


struct Graph {
int N;
int **matrix;
} * graph;

— matrix would be int* as well

— That's my struct that's why doing int **