日志

摘要: 背景 封装日志API供平时代码学习使用,顺便学习一下相关的知识点: 变参函数 时间的格式化输出 c语言版本 log.h #ifndef _LOG_H_ #define _LOG_H_ #include <stdarg.h> #include <stdio.h> #include <time.h> # 阅读全文
posted @ 2019-12-29 13:30 sermatec江 阅读(150) 评论(0) 推荐(0) 编辑

链表

摘要: 背景 链表是一种非常经典的数据结构,对链表的基本操作有“增”,“删”,“改”,“查”,“遍历”,“反转”等; 通过测试代码的方式能更好的理解链表的操作原理,以及将其运用到今后的代码开发中。 代码 链表反转(逆序) #include<iostream> using namespace std; // 阅读全文
posted @ 2019-12-28 21:52 sermatec江 阅读(174) 评论(0) 推荐(0) 编辑

vim配置手册

摘要: 背景 个人vim显示风格,以及一些控制命令的备忘。 系统信息: Linux debian9 4.9.0-7-amd64 #1 SMP Debian 4.9.110-1 (2018-07-05) x86_64 GNU/Linux 编译器和vim等辅助程序,都是系统自带的原始版本。 2019/12/30 阅读全文
posted @ 2019-12-28 19:35 sermatec江 阅读(155) 评论(0) 推荐(0) 编辑

shell编程

摘要: 背景 收集一些平时可能会用到的Linux脚本。 内容 tcp连接统计 netstat -an | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' 删除空行 sed '/^$/d' file.txt 删除以 '#'开头的行 sed '/^ 阅读全文
posted @ 2019-12-28 19:30 sermatec江 阅读(87) 评论(0) 推荐(0) 编辑

时间戳

摘要: #include <time.h> #include <sys/time.h> #include <stdio.h> char * getTimestamp() { struct timeval tv; struct tm tm_time; gettimeofday(&tv, NULL); gmti 阅读全文
posted @ 2019-12-28 19:22 sermatec江 阅读(143) 评论(0) 推荐(0) 编辑

注册回调

摘要: 背景 总结一下在c,c++里注册回调的几种用法 用法 c语言 #include <iostream> using namespace std; int demo(char *str1, char *str2) { printf("print in demo(): %s, %s\n", str1, s 阅读全文
posted @ 2019-12-28 19:09 sermatec江 阅读(406) 评论(0) 推荐(0) 编辑

函数strlen入参空指针引发的段错误

摘要: 背景 在工作中调试sqlite3相关代码的时候,调用printf()打印sqlite3_exec()的执行日志;因为sqlite3_exec()保存日志的参数传入时为NULL,且没有执行错误,所以再传入printf()时仍然为NULL;如果判断日志不为空时才打印,则无段错误。 分析 Core was 阅读全文
posted @ 2019-12-18 11:41 sermatec江 阅读(2258) 评论(0) 推荐(0) 编辑

Makefile

摘要: 序 linux下的c/c++编译代码通常需要自己写用于本程序的makefile文件,而事先准备好一个通常的、符合自己编程习惯的模板是可以加快你的编译工作。 在我看来,一个通常模板应,应具备几个必要的功能: 自动匹配依赖 添加目标和依赖的搜索路径 允许多目标编译 可生成库文件 c程序和c++程序编译快 阅读全文
posted @ 2019-12-12 18:13 sermatec江 阅读(134) 评论(0) 推荐(0) 编辑

linux终端命令行前缀设置为“当前目录”(非绝对路径)

摘要: linux终端命令行前缀设置为“当前目录” 阅读全文
posted @ 2019-12-12 11:38 sermatec江 阅读(915) 评论(0) 推荐(0) 编辑