static变量和函数如何巧妙调用
摘要:app.c 和 main.c 之间,在main.c中调用app.c的static变量和函数,需要利用一个结构体结合指针通过传地址的方式间接访问。 app main struct { int , func()}作为一种通道或载体 直接上一个代码: /*main.c*/ #include "common
阅读全文
mmap代替通用IO读取文件数据(curious)
摘要:提供一份测试demo: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <sys/fil
阅读全文
进程间文件读写锁的应用
摘要:直接提供一份文件锁的demo: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> /*check lock
阅读全文
一个lseek引起的思考
摘要:先看一段代码: int find_value(int fd) { int ret; char buff[8] = ""; struct timeval st,ed; long long delta; gettimeofday(&st,NULL); ret = read(fd,buff,sizeof(
阅读全文
删除双向链表的其中一个节点
摘要:以B作为删除的节点,代码思路如下: { line *temp = head; while(temp) { if (temp.data == date) { //B as temp temp->next->prev = temp->prev; //M1 temp->prev->next = temp-
阅读全文
双向链表的三种插入方法研究
摘要:1. 初始化一个双向链表。 2. 具体方法插入,每个节点可以存在如下结构: struct node_each node{ int data; struct node_each *prev; struct node_each *next; }; A. 头插入法 代码思路: { D->next = he
阅读全文