会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Chris83
博客园
首页
新随笔
联系
订阅
管理
2018年8月24日
sort、qsort排序
摘要: 1:qsort和sort只能对连续内存的数据进行排序,像链表map这样的结构是无法排序 2:qsort 示例 /* void qsort(void*base, // 待排序数组首地址 * size_t num, // 数组中待排序元素数量 * size_t width, // 各元素的占用空间大小
阅读全文
posted @ 2018-08-24 10:41 Chris83
阅读(566)
评论(0)
推荐(0)
2018年8月23日
文件(文本、二进制)读写,利用popen读取linux命令读取结果
摘要: 1 文件打开方式介绍 /* r :读操作,文件指针指向文件头 (若不存在则打开失败) r+ :读、写操作,文件指针指向文件头 (若不存在则打开失败,若存在则清空文件) w :写操作,文件指针指向文件头 (若不存在则新建,若存在则清空文件) w+ :读、写操作,文件指针指向文件头 (若不存在则新建,若
阅读全文
posted @ 2018-08-23 13:53 Chris83
阅读(3649)
评论(0)
推荐(0)
检查文件、目录是否存在,检查文件是否为空
摘要: 1 检查文件是否存在 2 检查文件是否为空
阅读全文
posted @ 2018-08-23 13:39 Chris83
阅读(1302)
评论(0)
推荐(0)
2018年8月22日
使用正则表达式检查IP地址是否合法
摘要: #include #include #include #include #include /* 编译命令: gcc -o test test.c 执行命令: ./test "192.168.1.1" 编写正则表达式 */ #define IP_V4_PATTERN \ "^([0-9]|[1-9][0-9]|1[0-9]{1,2}|2[0-4][0-9]|25[0-5])\ .(...
阅读全文
posted @ 2018-08-22 14:36 Chris83
阅读(1392)
评论(0)
推荐(0)
2018年8月14日
读取指定目录下的所有文件和目录
摘要: #include #include #include #include #include /* g++ -o test test.cc */ int main(int argc, char *argv[]) { /**打开指定路径,将路径下的目录和文件列表保存到DIR内*/ DIR *dirptr = NULL; if ((dirptr = opendir("...
阅读全文
posted @ 2018-08-14 16:44 Chris83
阅读(390)
评论(0)
推荐(0)
2018年8月3日
linux c的四种定时方式(sleep/usleep/select/ioctl)
摘要: 1:sleep() 最小单位秒。使用sleep/ulseep/select时,因为线程会进入休眠状态,再唤醒, 若单次执行问题不大,若是循环执行次数较多,则差别很大。 2:ulseep() 最小单位微秒。 3:select() 最小单位微秒,再循环体内使用时,每次使用都需要赋值。 4:rtc() 使
阅读全文
posted @ 2018-08-03 17:31 Chris83
阅读(1538)
评论(0)
推荐(0)
linux 时间格式转换
摘要: 1:头文件 2:取得当前时间 精确到秒 转换为日期形式 3:取得当前时间 精确到微妙 转换为日期形式 4:将"YYYY-MM-DD hh:mm:ss"格式的时间转换为秒 5:ctime 将时间转化为"Mon Nov 7 09:52:59 2016"形式 6:sleep select使用
阅读全文
posted @ 2018-08-03 16:05 Chris83
阅读(8053)
评论(0)
推荐(0)
2018年8月1日
删除行字符串开头的空格、tab 、行结尾的空格、tab和换行
摘要: int deleteSpaceEnterTab(char* srcstr) { if (NULL == srcstr) { printf("parameter error\n"); return -1; } /* 删除行尾的换行符 */ int tmpLen = strlen(srcstr); while ('\r' == ...
阅读全文
posted @ 2018-08-01 13:23 Chris83
阅读(842)
评论(0)
推荐(0)
按照指定字符分割字符串,并返回结果
摘要: 1:编译环境 2:示例代码 3:输出结果
阅读全文
posted @ 2018-08-01 11:31 Chris83
阅读(985)
评论(0)
推荐(0)
2018年7月27日
linux下查看cpu内存网卡发行版本信息
摘要: 1: 查看 linux版本 2:查看CPU 2.1 查看物理CPU个数 2.2 查看每个物理CPU中core的个数(即核数) 3:查看内存 查看物理内存 4:查看网卡
阅读全文
posted @ 2018-07-27 20:32 Chris83
阅读(442)
评论(0)
推荐(0)
下一页
公告