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;
}
相关推荐
若汝棋茗6 分钟前
C# 异步方法中缺少 `await` 运算符的隐患与解决方案
开发语言·c#·await
江畔柳前堤7 分钟前
PyQt学习系列05-图形渲染与OpenGL集成
开发语言·javascript·人工智能·python·学习·ecmascript·pyqt
黎相思15 分钟前
特殊类设计
开发语言·c++
君鼎18 分钟前
C++——volatile
开发语言·c++
Uncertainty!!1 小时前
C++系统IO
开发语言·c++
玉笥寻珍1 小时前
从零开始:Python语言进阶之多态
开发语言·python
长勺1 小时前
单例模式总结
java·开发语言·单例模式
ZFJ_张福杰1 小时前
【Flutter】多语言适配-波斯语RTL从右到左
java·开发语言
tanyongxi661 小时前
C++ 继承详解:基础篇(含代码示例)
开发语言·c++
yaoxin5211231 小时前
86. Java 数字和字符串 - 数字
java·开发语言