【发布时间】:2020-05-09 01:23:33
【问题描述】:
我有一个包含结构节点的作业,在其中一个函数中,写的是 current->next->Firstname,我的问题是: current->next->Firstname 的数据类型是什么? 谢谢 . 代码的相关部分如下:
typedef struct node
{
char Lastname[50];
char Firstname[50];
char Initials[50];
char Mobile[50];
char Class[50];
char InitialSort[50];
char RandomSort[50];
struct node *next;
} node;
node *HEAD=NULL;
// more code here.
void sortedInsert(node** head_ref,node* new_node)
{
node* current;
// Special case for the head end
if (*head_ref == NULL || (*head_ref)->Firstname >= new_node->Firstname)
{
new_node->next = *head_ref;
*head_ref = new_node;
}
else
{
// Locate the node before the point of insertion
current = *head_ref;
while (current->next!=NULL && strcmp(current->next->Firstname, new_node->Firstname)<0 )
{
current = current->next;
}
new_node->next = current->next;
current->next = new_node;
}
}
【问题讨论】:
-
你的问题有点不清楚。 “具有类似说选项的数据类型”。什么是“选项”?它没有显示在您的代码中,也不是本机数据类型。
-
@Jeroen Van de Kaai 至于我,我还没有理解这个问题。
-
如果 option = current->next->Firstname,我应该如何删除选项? int, char char* , node* 等
-
你们,我只有 7 点声望点,你却把我击倒了。我试图让我的问题尽可能清楚。给新人一个机会...
-
char *option = current->next->Firstname。但请注意,option将成为指向原始数据的指针。这不是副本。
标签: c sorting pointers linked-list structure