Тема: Вопрос по С++
Смотрел решение задачи на граф. И увидел
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <assert.h>
#define MAXN (100010)
typedef struct tag_node_t {
int num;
tag_node_t* next;
} node_t;
typedef node_t* list_t;
list_t adj[MAXN] = {0};
int res[MAXN] = {0};
int color[MAXN] = {0};
int count = 0;
int N = 0;
int M = 0;
void init() {
for (int i = 1; i <= M; i++) {
adj[i] = (list_t)malloc(sizeof(node_t));
assert(NULL != adj[i]);
adj[i]->num = 0;
adj[i]->next = NULL;
}
}
Но не понял момента когда используется
adj[i] = (list_t)malloc(sizeof(node_t));
assert(NULL != adj[i]);