文章分类 -  永远的c/c++

1 2 下一页

c语言:str.c copypath
摘要:#include <stdio.h> #include <string.h> static void copypath(const char *src, char *dst, size_t dstlen) { char *end = dst + dstlen - 1; /* Copy the str 阅读全文

posted @ 2021-01-19 18:23 lydstory 阅读(79) 评论(0) 推荐(0) 编辑

c语言:fprintf pid_t
摘要:#include <stdio.h> #include <signal.h> #include <unistd.h> #include <getopt.h> static pid_t PidOutPut (char *path) { FILE *fp; pid_t pid; pid = getpid 阅读全文

posted @ 2021-01-19 17:11 lydstory 阅读(142) 评论(0) 推荐(0) 编辑

c语言基础:char写入一个文件
摘要:#include <stdio.h> #include <string.h> int write_change_policy(const char* filename,char* buf_policy) { FILE *fp = NULL; fp = fopen(filename,"w+"); if 阅读全文

posted @ 2021-01-10 00:56 lydstory 阅读(456) 评论(0) 推荐(0) 编辑

c语言基础:linux运行popen命令返回结果
摘要:#include <stdio.h> #include <string.h> #define BUF_SIZE 1024 #define MAX_NAME_SIZE 1024 int running_command(const char *command,char *result) { FILE * 阅读全文

posted @ 2021-01-10 00:46 lydstory 阅读(665) 评论(0) 推荐(0) 编辑

c语言基础:判断系统多少位
摘要:int get_sys_type(char *dst) { void *ptr = NULL; if (sizeof(ptr) == 4) sprintf(dst,"32"); else sprintf(dst,"64"); return 0; } int main() { char paht[25 阅读全文

posted @ 2021-01-10 00:43 lydstory 阅读(209) 评论(0) 推荐(0) 编辑

c语言基础:cutstring
摘要:#include <memory.h> //从文件件路径中获取文件名 void GetFileName(char *path,char *filename) { char *ptr = NULL; ptr = strrchr(path,'/'); if (!ptr) return; memcpy(f 阅读全文

posted @ 2021-01-10 00:31 lydstory 阅读(181) 评论(0) 推荐(0) 编辑

c语言基础:路径中获取文件名
摘要:#include <memory.h> //从文件件路径中获取文件名 void GetFileName(char *path,char *filename) { char *ptr = NULL; ptr = strrchr(path,'/'); if (!ptr) return; memcpy(f 阅读全文

posted @ 2021-01-10 00:19 lydstory 阅读(3738) 评论(0) 推荐(0) 编辑

c语言基础:memset memory
摘要:#include <string.h> #include <stdio.h> int main(int argc, char **argv) { char p[32]; char q[32]; strcpy(p, "123456789"); strcpy(q, "987654321"); print 阅读全文

posted @ 2021-01-09 07:45 lydstory 阅读(91) 评论(0) 推荐(0) 编辑

c语言基础: calloc
摘要:函数名: calloc 函数原型:void* calloc(unsigned int num,unsigned int size); 功能:在内存的动态存储区中分配num个长度为size的连续空间,函数返回一个指向分配起始地址的指针;如果分配不成功,返回NULL。 #define XCALLOC(x 阅读全文

posted @ 2021-01-08 07:45 lydstory 阅读(529) 评论(0) 推荐(0) 编辑

c语言基础:linux ssize_t(signed int)
摘要:ssize_t与size_t-linux ssize_t: signed size_t [注释:signed 有符号] size_t: 标准C库中定义的,应为unsigned int [注释:unsigned 无符号] 一、size_t 增强移植性: [注释:不同的系统上,定义size_t可能不一样 阅读全文

posted @ 2021-01-08 04:35 lydstory 阅读(646) 评论(0) 推荐(0) 编辑

c语言基础: define改变变量值
摘要:#include <stdio.h> static char* g_templname[2] = { "blacknamelist", "whitenamelist" }; #define ChangState(who,state) \ do { \ who = state; \ }while (0 阅读全文

posted @ 2021-01-08 04:17 lydstory 阅读(1003) 评论(0) 推荐(0) 编辑

c语言基础: static char*数组
摘要:#include <stdio.h> static char* g_templname[2] = { "blacknamelist", "whitenamelist" }; int main() { printf("%s\n",g_templname[1]); printf("Hello, Worl 阅读全文

posted @ 2021-01-08 03:43 lydstory 阅读(913) 评论(0) 推荐(0) 编辑

C++ vector的reserve和resize详解
摘要:vector 的reserve增加了vector的capacity,但是它的size没有改变!而resize改变了vector的capacity同时也增加了它的size!原因如下: reserve是容器预留空间,但在空间内不真正创建元素对象,所以在没有添加新的对象之前,不能引用容器内的元素。加入新的 阅读全文

posted @ 2019-12-03 19:51 lydstory 阅读(500) 评论(0) 推荐(0) 编辑

回调中智能指针unique_ptr
摘要:std::unique_ptr<SocksClient> sockclient = std::unique_ptr < SocksClient > (new SocksClient()); sockclient.get()->socks_client_open(1); 回调中定义类的智能指针对象 一 阅读全文

posted @ 2019-11-29 11:04 lydstory 阅读(194) 评论(0) 推荐(0) 编辑

strstr分割消息(太原始)
摘要:strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串 阅读全文

posted @ 2019-11-14 14:48 lydstory 阅读(128) 评论(0) 推荐(0) 编辑

SIGALRM信号
摘要:signal(SIGALRM, alarmhandle); 表示给当前进程注册SIGALRM信号处理代码,如果收到SIGALRM信号,就会去执行alarmhandle函数 实际运用中,需要对不同到signal设定不同的到信号处理函数,SIG_IGN忽略/SIG_DFL默认,这俩宏也可以作为信号处理函 阅读全文

posted @ 2019-11-13 18:54 lydstory 阅读(741) 评论(0) 推荐(0) 编辑

msleep
摘要:msleep是休眠函数,它不涉及忙等待.用msleep(200)的时候实际上延迟的时间,大部分时候是要多于200ms,是个不定的时间值. 阅读全文

posted @ 2019-11-13 18:32 lydstory 阅读(394) 评论(0) 推荐(0) 编辑

static 与 extern
摘要:(2)修饰全局变量 对于一个全局变量,它既可以在本源文件中被访问到,也可以在同一个工程的其它源文件中被访问(只需用extern进行声明即可)。 如: 有file1.c int a=1; file2.c #include<stdio.h> extern int a; int main(void) { 阅读全文

posted @ 2019-11-13 17:19 lydstory 阅读(90) 评论(0) 推荐(0) 编辑

枚举错误码结构体数组
摘要: 阅读全文

posted @ 2019-09-23 08:55 lydstory 阅读(304) 评论(0) 推荐(0) 编辑

loki库(设计模式)
摘要:https://blog.csdn.net/chollima/article/details/8158580 阅读全文

posted @ 2019-09-21 15:21 lydstory 阅读(272) 评论(0) 推荐(0) 编辑

1 2 下一页

导航

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