代码
c丶happy
这个作者很懒,什么都没留下…
展开
-
单链表常用算法(创建节点、插入链表、遍历、删除、反转)
单链表常用算法创建节点插入链表头插法尾插法遍历链表删除节点链表反转创建节点// 创建一个节点,data为一个节点的有效数据struct node *creat_node(int data){ struct node *p = (struct node *)malloc(1*NODE_LEN); if(NULL == p){ printf("fail to malloc.\n"); return NULL; } memset(p, 0, NODE_LEN); p->data原创 2021-09-09 11:16:41 · 502 阅读 · 0 评论 -
UDP编程示例(sendto、bind、recvfrom)
一、示例1: 往网络调试助手发送信息#include <sys/types.h>#include <sys/socket.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#define N 128原创 2021-03-13 15:58:15 · 787 阅读 · 1 评论 -
C语言 数组表示方法与区分
C语言 数组表示方法与区分#include <stdio.h>int main(){ int a[5] = {1,2,3,4,5}; int *p = &a[0]; int (*pa)[5] = &a; 定义数组指针,指向数组a int i; for(i = 0; i < 5; i++){ //数组下标法 printf("%d ",a[i]); } printf("\n"); f原创 2021-02-16 15:42:58 · 2090 阅读 · 0 评论 -
C语言 用指针数组实现字符串的排序
C语言 用指针数组实现字符串的排序#include <stdio.h>#include <stdlib.h>#include <string.h>void sort(char *s[], int len){ int i,j; char *temp = (char *)malloc(sizeof(char) * 30); for(i = 0; i < len-1; i++){ for(j = 0; j < le原创 2021-02-16 15:40:30 · 5196 阅读 · 1 评论 -
C语言 冒泡排序(回调函数法)
冒泡排序(C语言)#include <stdio.h>int small_big(int x, int y){ return (x > y) ? 1 : 0;}int big_small(int x, int y){ return (x < y) ? 1 : 0;}void sort(int cmd[], int len, int (*p)(int, int)) { //函数指针,指向b原创 2021-02-15 21:47:49 · 224 阅读 · 0 评论