c语言程序解释

2024-11-16 01:20:34
推荐回答(1个)
回答1:

定义函数,没参数,返回值是结构体指针类型,模拟c++中的new操作符,如果你稍微了解c++就好办了

struct relationer *new()
{
struct relationer *node;
node = malloc(sizeof(struct relationer));//分配了内存
//下面给字符串初始化为空字符串,指针置空
strcpy(node->name,"");
strcpy(node->title,"");
strcpy(node->mobile,"");
strcpy(node->telephone,"");
node->next = NULL;
return node;//返回指针,需要在用过之后在外面释放
}