Tag: 边缘

为什么我的c代码从txt文件生成图表不起作用?

我对c语言有很多困难。 我正在尝试根据这个问题从txt文件生成图表: 为什么我在下面的代码中出现分段错误? 根据我的最佳答案进行更改后,generate_nodes方法正在运行。 但是现在我在generate_edges方法中遇到了问题。 图节点类型: #ifndef Graph_Structure #define Graph_Structure #include struct Graph_Node{ int id; char node_name[100]; bool path; struct Graph_Node* next; struct Graph_Node* edge; struct Graph_Node* next_edge; }; typedef struct Graph_Node graph_node; #endif generate_edges方法: int generate_edges(graph_node **graph, const char *file_name){ FILE *fp = fopen(file_name, “r”); if(fp == NULL) { fprintf(stderr, “Error opening file %s: […]