1
I am implementing a work of Graph Theory that deals with the game Flood-It which is a problem in flooding in Graphs.
I’m right at the beginning and implemented the graph structure yet. The structure of it is:
typedef struct {
int V;
int A;
int **adj;
} Grafo;
The third field must be a pointer to the adjacency matrix of the graph. The function that creates the matrix is the following:
static int ** MATRIZADJint(int linhas,const int colunas, int valor){
int **m = malloc(linhas * sizeof(int *)); // aloca linhas
for (vertice i = 0; i < colunas; ++i)
m[i] = malloc(colunas * sizeof(int)); // aloca colunas
for (vertice i = 0; i < linhas; ++i)
for (vertice j = 0; j < colunas; ++j)
m[i][j] = valor; // preenche a matriz de adjacencias inicialmente com 0's
return m;
}
Unfortunately Visual Studio is not accepting the implementation, presenting the following error message:
malloc - a value of type "void *" cannot be used to initialize an entity of type "int **" = - a value of type "void *" cannot be used to initialize an entity of type "int **"
Does anyone know what it can be?
Related: https://answall.com/q/95784/132
– Victor Stafusa