
c
c语言
kong-kong
记录流水账
展开
-
指针赋值 =*p =&p
=*p =&p原创 2022-10-19 17:17:19 · 360 阅读 · 0 评论 -
c语言的true、false
c语言true、false原创 2022-10-19 09:12:50 · 538 阅读 · 0 评论 -
string.h
strcasecmp原创 2022-10-19 08:45:51 · 146 阅读 · 0 评论 -
C语言static关键字用法
static关键字原创 2022-10-18 10:07:21 · 220 阅读 · 0 评论 -
函数指针-kernel例子
int ep_call_nested(struct nested_calls *ncalls, int max_nests, int (*nproc)(int *, int *, int))原创 2022-10-12 16:29:57 · 179 阅读 · 0 评论 -
#define EP_UNACTIVE_PTR ((void *) -1L)
#define EP_UNACTIVE_PTR ((void *) -1L)原创 2022-10-12 15:34:36 · 146 阅读 · 0 评论 -
c函数指针
#include <stdio.h>void echo(void) { printf("===========echo===================\n");}void echo1(void) { printf("===========echo1===================\n");}long sum(int a,long b){ return a+b;}int main(){ // 定义函数指针 void (.原创 2022-05-19 23:44:02 · 163 阅读 · 0 评论 -
char*
例子 char *str = "12345678"; for(char i=0;i<8;i++) { printf("str[%d] = %c(%d) \n", i,*str,*str); str++; }输出str[0] = 1(49)str[1] = 2(50)str[2] = 3(51)str[3] = 4(52)str[4] = 5(53)str[5] = 6(54)str[6] = 7(55)str[7] = 8(56)原创 2022-05-05 23:07:33 · 293 阅读 · 0 评论 -
gdb调试查看内存数据
gdb查看内存数据格式x /nfuf 显示方式x 按十六进制格式显示变量。d 按十进制格式显示变量。u 按十进制格式显示无符号整型。o 按八进制格式显示变量。t 按二进制格式显示变量。a 按十六进制格式显示变量。i 指令地址格式c 按字符格式显示变量。f 按浮点数格式显示变量。u 显示方式b表示单字节,h表示双字节,w表示四字节,g表示八字节测试# 20: 数量# x:16进制# h: 双字节x /20xh 0x61FDFC参考文档参考文档..原创 2022-01-28 15:52:49 · 6140 阅读 · 0 评论 -
dictEntry-单向列表
demo#include <stdio.h>#include <stdlib.h>typedef struct dictEntry { void *key; /** key */ void *val; struct dictEntry *next;} dictEntry;typedef struct dict { dictEntry* dictEntry;}dict;int main(){ int nums[10原创 2022-01-28 13:06:10 · 917 阅读 · 0 评论 -
c指针-用于忘记看看
例子int main() { int a = 10; // *b的类型是int int *b = &a; // b存的是a地址 // **c的类型是int int **c = &b; // *c = b存的地址 = a 地址 c = b的地址 cout << "&a=" << &a << endl; cout << "b=" << b <&l原创 2021-12-28 18:32:53 · 505 阅读 · 2 评论 -
gdb简单调试
demo1int main() { const char src[] = "abcdefghi"; const char dest[] = "123456789"; cout << "src.first.address=" << &src << endl; cout << "dest.first.address=" << &dest << endl; return 1;原创 2021-12-28 18:21:05 · 401 阅读 · 0 评论 -
memmove
声明void *memmove(void *dest, const void *src, size_t n)参数dest – 指向用于存储复制内容的目标数组,类型强制转换为 void* 指针。src – 指向要复制的数据源,类型强制转换为 void* 指针。n – 要被复制的字节数。例子#include <iostream>using namespace std;int main() { const char src[] = "abcdefghi";原创 2021-12-28 18:20:04 · 261 阅读 · 0 评论 -
指针demo
demoarr[0] = ‘d’;arr[1] = ‘a’;// 2-5位存int的值168168arr[2-5] = 168168;int main3(){// char c[4];// int i=100;// *(int*)c = i; char arr[100]; arr[0] = 100; //d arr[1] = 'a'; char *p = (char*)&arr; cout << "addr原创 2021-11-16 22:45:19 · 548 阅读 · 0 评论 -
printf
format%d 十进制有符号整数%u 十进制无符号整数%f 浮点数(float)%lf 浮点数(double)%s 字符串%c 单个字符%p 指针地址demo char * str = "welcome to c!"; if(str[0]=='w'){ printf("first letter is %c \n",str[0]); printf("first letter is %s \n","w"); } printf("原创 2021-09-30 08:37:23 · 181 阅读 · 0 评论 -
eventpool
ep_op_has_event不是EPOLL_CTL_DEL事件,返回truelinuc/eventpool.hstatic inline int ep_op_has_event(int op){ return op != EPOLL_CTL_DEL;}原创 2021-09-30 02:43:37 · 247 阅读 · 0 评论 -
include/linux/list.h
list.hinclude/linux/list.hlist_add/** * list_add - add a new entry 添加新条目 * @new: new entry to be added 要添加的新条目 * @head: list head to add it after 列出要在其后添加的头 * * Insert a new entry after the specified head. 在指定的头部后插入一个新条目 * This is good for imple原创 2021-09-30 01:04:24 · 1157 阅读 · 0 评论 -
llinux内核等待队列之wait.h
init_waitqueue_func_entry使用自定义的函数作为等待队列中的进程唤醒事件static inline voidinit_waitqueue_func_entry(struct wait_queue_entry *wq_entry, wait_queue_func_t func){ wq_entry->flags = 0; wq_entry->private = NULL; wq_entry->func = func;}例子// 回调事件ep_p原创 2021-09-30 00:23:28 · 851 阅读 · 0 评论 -
define
定义函数#include <stdio.h>#include <string.h>#include <stdlib.h>// define 没有;#define MAX 100#define MULT(a,b) a * b#define MULT1(a,b) ((a) * (b))int main() { printf("max=%d \n",MAX); // #define起到的是替换作用,所以最后的表达式应该替换为 1 +原创 2021-09-29 11:23:54 · 199 阅读 · 0 评论 -
c在struct中定义函数
前沿想在结构体上定义函数,但是在c中不支持直接定义函数,我们可以通过定义函数指针的方式来实现typedef struct bookCreate { int (*hashcode)(const void *name); void *(*bookInit)(int id, const void *name);} bookCreate;例子#include <stdio.h>#include <string.h>#include <stdlib.h&g原创 2021-09-29 09:47:24 · 4620 阅读 · 1 评论 -
sizeof
指针大小指针 X86占4个字节 X64占8个字节int b = 10;int *pb = &b;printf("b.size=%d b=%p \n",sizeof(b),b);printf("pb.size=%d pb=%p \n",sizeof(pb),pb);b.size=4 b=000000000000000Apb.size=8 pb=000000000061FE04...原创 2021-03-05 23:04:34 · 246 阅读 · 0 评论 -
结构数组传递
结构数组声明struct book as[ARRAYSIZE];例子//// Created by kongqi on 2021/9/28.//#include <stdio.h>#include <stdlib.h>#include <string.h>#define SIZE 10#define ARRAYSIZE 6struct book{ int id;// char name[SIZE]; char * na原创 2021-09-28 23:12:30 · 554 阅读 · 0 评论 -
struct指针传递
代码#include <stdio.h>#include <stdlib.h>#include <string.h>struct book{ int id; char* name;};static void readData(int fd, void * privdata) { struct book * b = privdata; printf("============================\n");原创 2021-09-28 21:43:19 · 209 阅读 · 0 评论