0 c linked-list
void insert_end()
{
struct node *nn=(struct node*)malloc(sizeof(struct node));
printf("Enter the data:");
scanf("%d",&nn->info);
nn->next=NULL;
if(first==NULL)
{
first=nn;
first->next=first;
}
else
{
temp=first;
while(temp->next!=first)
temp=temp->next;
temp->next=nn;
nn->next=first;
printf("The address of the first node is %d", first);
printf("The address of the last node is %d", nn->next);
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个循环链接列表,C中的插入函数.
我需要表明第一个节点的地址和最后一个节点的链接部分具有相同的值,从而表明它是一个循环链表.
但我上面的代码给出了随机整数值..!
您可能想要打印地址 %p
printf("The address of the first node is %p",first);
printf("The address of the last node is %p",nn->next);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4591 次 |
| 最近记录: |