C语言相关内容模块

C语言相关内容模块

1、函数指针定义方式

函数指针的具体用法

2、静态链表实现


代码实现:

c 复制代码
#define _CRT_SECURE_NO_WARNINGS // 抑制 C4996 警告
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

// 链表节点类型定义
struct LinkNode
{
	int data;
	struct LinkNode *next;

};

void test() {

	// 创建5个独立的节点
	struct LinkNode noed1 = { 10,NULL };
	struct LinkNode noed2 = { 20,NULL };
	struct LinkNode noed3 = { 30,NULL };
	struct LinkNode noed4 = { 40,NULL };
	struct LinkNode noed5 = { 50,NULL };

	// 创建链表
	noed1.next = &noed2;
	noed2.next = &noed3;
	noed3.next = &noed4;
	noed4.next = &noed5;

	// 遍历链表
	struct LinkNode *pCurrent = &noed1;

	while (pCurrent !=NULL)
	{
		printf("%d\n", pCurrent->data);
		pCurrent = pCurrent->next;
	}

}

int main() {

	test();
	system("pause");
	return 0;
}
相关推荐
siy233320 分钟前
[c语言日记] 数组的一种死法和两种用法
c语言·开发语言·笔记·学习·链表
njxiejing38 分钟前
Python NumPy安装、导入与入门
开发语言·python·numpy
Rhys..1 小时前
Python&Flask 使用 DBUtils 创建通用连接池
开发语言·python·mysql
土了个豆子的1 小时前
04.事件中心模块
开发语言·前端·visualstudio·单例模式·c#
@菜菜_达2 小时前
Lodash方法总结
开发语言·前端·javascript
GISer_Jing2 小时前
低代码拖拽实现与bpmn-js详解
开发语言·javascript·低代码
@areok@2 小时前
C++mat传入C#OpencvCSharp的mat
开发语言·c++·opencv·c#
小王C语言2 小时前
【C++进阶】---- map和set的使用
开发语言·c++
Elnaij2 小时前
从C++开始的编程生活(8)——内部类、匿名对象、对象拷贝时的编译器优化和内存管理
开发语言·c++
yb0os13 小时前
RPC实战和核心原理学习(一)----基础
java·开发语言·网络·数据结构·学习·计算机·rpc