![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C
C语言
单林敏
心外无物,知行合一
CSDN 做为自己的简要易忘小知识点的记录,而自己的感想和长文一般发布在自己的个人blog,网址如下:
https://www.wolfdan.cn/
展开
-
iov数组中间加值
iovec的结构首先观察iovec的存储结构,就知道iovec数组一旦填充了值之后,就无法在iovec的base的尾部添加字符了因为这样会破坏后面的len,所以想要加值,就要重新生成一个iovec数组然后复制,或者是在尾部添加尾部添加演示#include <fcntl.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>原创 2021-10-31 14:50:26 · 180 阅读 · 0 评论 -
snprintf返回值判断-返回值深入实践分析
snprintf返回值判断-返回值深入实践分析#include <stdio.h> int main(){ char dest[50]; char* args = "wolfdan.cn"; int size = 15; int ret; // len(args) < size 情况 printf("写入args的长度为: %d, size 为 %d (args.len < size)\n", strlen(args), s原创 2021-08-10 17:17:55 · 1588 阅读 · 0 评论 -
字符拼接数字[最佳实践]
字符拼接数字在多进程环境中,防止多线程读写同一个文件,所以往往会加pid来分别写不同文件,防止错乱然后sprintf一般在项目中会宏定义成不要使用#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;所以最佳方法就是用snprintfchar *tmp_file_path = "some path";int INT_MAX_LEN = 10;int SPLIT_CHAR_LEN = 1;int pid = getpid();int file_p原创 2021-08-10 17:17:00 · 208 阅读 · 0 评论 -
CVAL,PVAL,SVAL宏定义
常规使用// smb 开源代码flags = IVAL(inhdr, SMB2_HDR_FLAGS);opcode = SVAL(inhdr, SMB2_HDR_OPCODE);源码中解释https://github.com/samba-team/samba/blob/master/lib/util/byteorder.h/* Unix SMB/CIFS implementation. SMB Byte handling Copyright (C) Andrew Tridg原创 2021-06-22 17:47:22 · 647 阅读 · 0 评论