随笔 - 192,  文章 - 0,  评论 - 2,  阅读 - 25万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  c 基本操作

linux 代码覆盖率 检测
摘要:gcc/g++自带了gcov 工具可以自动生成一个执行代码覆盖率信息的文件gcda。只需要带编译宏 -fprofile-arcs-ftest-coverage 就可以生成gcno文件 具体的信息可见 http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/Gcov-I 阅读全文
posted @ 2022-10-17 15:45 Malphite 阅读(336) 评论(0) 推荐(0) 编辑
linux串口编程设置
摘要:在嵌入式Linux中,串口是一个字设备,访问具体的串行端口的编程与读/写文件 的操作类似,只需打开相应的设备文件即可操作。串口编程特殊在于串 口通信时相关参数与属性的设置。嵌入式Linux的串口编程时应注意,若在根文件中没有串口设备文件,应使用mknod命令创建,这这里假设串口设备是 /dev/tt 阅读全文
posted @ 2022-10-12 09:44 Malphite 阅读(1076) 评论(0) 推荐(0) 编辑
xml、json解析与生成
摘要:XML 安装minixml 安装包获取地址 https://github.com/michaelrsweet/mxml/releases 或者官网:迷你 XML 2.8 (msweet.org) 安装 ./configure --host= --prefix= make sudo make inst 阅读全文
posted @ 2021-12-15 10:01 Malphite 阅读(260) 评论(0) 推荐(0) 编辑
线程的几种锁及基本操作
摘要:我们先来看一段代码: #include <stdio.h> #include <stdlib.h> #include <pthread.h> //创建两个线程,分别对两个全变量进行++操作,判断两个变量是否相等,不相等打印 int a = 0; int b = 0; // 未初始化 和0初始化的成员 阅读全文
posted @ 2021-12-09 10:25 Malphite 阅读(896) 评论(0) 推荐(0) 编辑
ioctl获取本机IP和MAC地址
摘要:#include <net/if.h> #include <sys/ioctl.h> #include <arpa/inet.h> #include <stdlib.h> #include <stdio.h> #define ETH_NAME "ens33" int main() { int soc 阅读全文
posted @ 2020-11-13 11:00 Malphite 阅读(419) 评论(0) 推荐(0) 编辑
map文件
摘要:https://www.cnblogs.com/gaotaozhaolei/archive/2008/02/02/1062155.html 阅读全文
posted @ 2020-04-20 08:33 Malphite 阅读(216) 评论(0) 推荐(0) 编辑
获取Linux的cpu占用率和 mem使用情况
摘要:参考:https://www.cnblogs.com/earvin/articles/11441366.html 阅读全文
posted @ 2020-04-10 15:01 Malphite 阅读(422) 评论(0) 推荐(0) 编辑
linux系统中socket错误码:EINTR和EAGAIN的处理
摘要:转自:https://blog.csdn.net/Windgs_YF/article/details/94559501 阅读全文
posted @ 2020-04-02 16:53 Malphite 阅读(842) 评论(0) 推荐(0) 编辑
linux c 产生随机数
摘要:rand函数: 头文件 #include<stdlib.h> 定义函数 int rand(void) 函数说明 rand()会返回一随机数值,范围在0至RAND_MAX 间。在调用此函数产生随机数前,必须先利用srand()设好随机数种子,如果未设随机数种子,rand()在调用时会自动设随机数种子为 阅读全文
posted @ 2020-03-05 14:29 Malphite 阅读(2079) 评论(0) 推荐(0) 编辑
linux/windows 双平台csv文件生成方法
摘要:逗号分隔值(Comma-Separated Values,CSV,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本)。 1、linux/windows 可移植 #include <stdio.h> int main() { FILE *fp; char 阅读全文
posted @ 2020-03-02 10:14 Malphite 阅读(1145) 评论(0) 推荐(0) 编辑
C/linux 产生随机字符串
摘要:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> char* genRandomString(int length) { int flag, i; char* string; srand((uns 阅读全文
posted @ 2020-02-12 11:31 Malphite 阅读(1580) 评论(0) 推荐(0) 编辑
浮点数NaN和INF(#IND, #INF)
摘要:NaN&INF定义在一些情况会出现无效的浮点数,例如除0,例如负数求平方根等,像这类情况,获取到的浮点数的值是无效的。 NaN 即 Not a Number 非数字 INF 即 Infinite 无穷大 通常无效浮点数的内存表示方法是: 根据IEEE 754标准:阶码全1,尾数全0表示无穷大INF。 阅读全文
posted @ 2019-12-19 17:22 Malphite 阅读(4216) 评论(0) 推荐(0) 编辑
深入理解pthread_cond_wait、pthread_cond_signal
摘要:LINUX环境下多线程编程肯定会遇到需要条件变量的情况,此时必然要使用pthread_cond_wait()函数。但这个函数的执行过程比较难于理解。 pthread_cond_wait()的工作流程如下(以MAN中的EXAMPLE为例): Consider two shared variables 阅读全文
posted @ 2019-11-08 13:18 Malphite 阅读(503) 评论(0) 推荐(0) 编辑
七、用户组
摘要:1、endgrent 表头文件 #include<grp.h> #include<sys/types.h> 定义函数 void endgrent(void); 函数说明 endgrent()用来关闭由getgrent()所打开的密码文件。 返回值 无 附加说明 无 2、endpwent 表头文件 # 阅读全文
posted @ 2019-08-31 17:37 Malphite 阅读(258) 评论(0) 推荐(0) 编辑
十二、格式化I/O
摘要:1、fprintf 表头文件 #include<stdio.h> 定义函数 int fprintf(FILE * stream, const char * format,.......); 函数说明 fprintf()会根据参数format 字符串来转换并格式化数据,然后将结果输出到参数stream 阅读全文
posted @ 2019-08-28 23:49 Malphite 阅读(223) 评论(0) 推荐(0) 编辑
十四、错误处理
摘要:1、ferror 表头文件 #include<stdio.h> 定义函数 int ferror(FILE *stream); 函数说明 ferror()用来检查参数stream 所指定的文件流是否发生了错误情况,如有错误发生则返回非0 值。 返回值 如果文件流有错误发生则返回非0 值。 2、perr 阅读全文
posted @ 2019-08-27 23:32 Malphite 阅读(142) 评论(0) 推荐(0) 编辑
八、数据结构和算法
摘要:1、crypt 表头文件 #define _XOPEN_SOURCE #include<unistd.h> 定义函数 char * crypt (const char *key,const char * salt); 函数说明 crypt()将使用Data Encryption Standard ( 阅读全文
posted @ 2019-08-26 22:49 Malphite 阅读(186) 评论(0) 推荐(0) 编辑
六、数学函数
摘要:1、abs 表头文件 #include<stdlib.h> 定义函数 int abs (int j) 函数说明 abs () 用来计算参数j的绝对值,然后将结果返回。 返回值 返回参数j的绝对值结果。 2、acos 表头文件 #include <math.h> 定义函数 double acos (d 阅读全文
posted @ 2019-08-25 16:33 Malphite 阅读(248) 评论(0) 推荐(0) 编辑
五、内存及字符串操作
摘要:1、bcmp 表头文件 #include<string.h> 定义函数 int bcmp ( const void *s1,const void * s2,int n); 函数说明 bcmp()用来比较s1 和s2 所指的内存区间前n 个字节,若参数n为0,则返回0。 返回值 若参数s1 和s2 所 阅读全文
posted @ 2019-08-25 15:40 Malphite 阅读(278) 评论(0) 推荐(0) 编辑
四、日期时间
摘要:1、asctime 表头文件 #include<time.h> 定义函数 char * asctime(const struct tm * timeptr); 函数说明 asctime()将参数timeptr 所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。 阅读全文
posted @ 2019-08-24 23:34 Malphite 阅读(209) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示