c - 将节点添加到结束函数有什么作用
问题描述
我想知道这个add_node_end
函数到底是做什么的:
typedef struct listint_s {
char *a;
char *b;
struct listint_s *next;
} listint_t;
listint_t *add_node_end(listint_t **head, char *a, char *b) {
listint_t *tmp_node, *new_node;
new_node = malloc(sizeof(listint_t));
if (!new_node)
return (NULL);
new_node->a = a;
new_node->b = b;
new_node->next = NULL;
if (!*head) {
*head = new_node;
return (*head);
}
tmp_node = *head;
while (tmp_node->next)
tmp_node = tmp_node->next;
tmp_node->next = new_node;
return (*head);
}
解决方案
推荐阅读
- c# - 从 ML.Net fasttree 模型中获取 RegressionTree
- ethernet - myarduinoprojects.com 的 mgsmodbus 如何使用
- android - 流不发射项目
- python - 使用openpyxl删除Excel中的重复项和相邻单元格
- mysql - 将第二个 MySQL 表中的数据添加到第一个表的结果中
- c++ - 掷骰子游戏做while循环不满足退出条件
- ruby-on-rails - 如何按每个字符在哈希数组中搜索
- asp.net - 使用实体框架将数据导出到 csv
- angular - 服务的 BehaviorSubject 在两个不同的组件调用之间设置为 null
- php - AJAX 不发布任何数据