⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linklist.c

📁 C源码集
💻 C
字号:
#include <stdio.h>#include <string.h>int main (){struct node{	char name [30];	struct node *nextperson;};struct node m1 = {"Chris", NULL};// note - could not have pointer to m2 as m2 not defined yetstruct node m2 = {"Kelly", &m1};struct node m3 = {"Les", &m2};struct node m4 = {"Nicky", &m3};struct node m5, m6;// to print and traverse the liststruct node *current = &m4;while (current != NULL){	printf("%s\n", current->name);	current = current -> nextperson;}printf("\nAdd an element to the beginning\n");strcpy(m5.name, "Ali");m5.nextperson = &m4;current = &m5;while (current != NULL){	printf("%s\n", (*current).name);	current = (*current).nextperson;}printf("\nAdd a person to the middle\n");printf("What is the name of the extra person?");scanf("%s", &m6.name);m6.nextperson = &m2;m3.nextperson = &m6;current = &m5;while (current != NULL){	printf("%s\n", (*current).name);	current = (*current).nextperson;}return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -