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;
}
相关推荐
应用市场1 小时前
构建自定义命令行工具 - 打造专属指令体
开发语言·windows·python
Dfreedom.2 小时前
一文掌握Python四大核心数据结构:变量、结构体、类与枚举
开发语言·数据结构·python·变量·数据类型
一半烟火以谋生2 小时前
Python + Pytest + Allure 自动化测试报告教程
开发语言·python·pytest
虚行2 小时前
C#上位机工程师技能清单文档
开发语言·c#
小羊在睡觉3 小时前
golang定时器
开发语言·后端·golang
CoderCodingNo3 小时前
【GESP】C++四级真题 luogu-B4068 [GESP202412 四级] Recamán
开发语言·c++·算法
Larry_Yanan3 小时前
QML学习笔记(四十四)QML与C++交互:对QML对象设置objectName
开发语言·c++·笔记·qt·学习·ui·交互
百锦再4 小时前
对前后端分离与前后端不分离(通常指服务端渲染)的架构进行全方位的对比分析
java·开发语言·python·架构·eclipse·php·maven
Want5954 小时前
C/C++大雪纷飞①
c语言·开发语言·c++
有时间要学习5 小时前
Qt——窗口
开发语言·qt