随笔分类 -  c/c++

C语言,在函数中malloc,关注实参与形参
摘要:下面的 employee.c 演示了如何在函数中通过malloc分配堆内存,并返回调用方。 为关注重点,把memset()和free()都省了。 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct emp 阅读全文
posted @ 2020-04-11 00:22 god with us 阅读(707) 评论(0) 推荐(1)
c语言中实践里氏代换原则
摘要:任何基类可以出现的地方,都可以用子类来替代。 下面摘录一个单链表的示例: #include <stdio.h> #include <stdlib.h> #include <string.h> struct node { struct node * next; }; struct list { str 阅读全文
posted @ 2020-04-08 14:04 god with us 阅读(257) 评论(0) 推荐(0)
C语言版的twitter分布式全局唯一标识snowflake Id
摘要:c snowflake id twitter 阅读全文
posted @ 2020-04-01 00:19 god with us 阅读(572) 评论(0) 推荐(0)