随笔分类 -  C/C++

1
摘要:// 1. retrieve the vertex/fragment source code from filePath std::string vertexCode; std::string fragmentCode; std::ifstream vShaderFile; std::ifstrea 阅读全文
posted @ 2023-03-30 09:55 刘大侠GG_B 阅读(34) 评论(0) 推荐(0)
摘要:#include <iostream> #include <fstream> using namespace std; int main() { ostream hexout(cout.rdbuf()); hexout.setf(ios::hex, ios::basefield); hexout.s 阅读全文
posted @ 2021-11-19 17:50 刘大侠GG_B 阅读(54) 评论(0) 推荐(0)
摘要:###网络服务器编程相关 服务端主动关闭连接的缺点之一是会多占用服务器资源。服务端主动关闭连接之后会进入TIME_WAIT状态,在一段时间之内持有(hold)一些内核资源。如果并发访问量很高,就会影响服务端的处理能力。这似乎暗示我们应该把协议设计为客户端主动关闭,让TIME_WAIT状态分散到多台客 阅读全文
posted @ 2021-05-14 10:12 刘大侠GG_B 阅读(106) 评论(0) 推荐(0)
摘要:###1: 将[first,last)范围内的元素重新排列到下一个字典顺序上更大的排列 详见链接 template bool next_permutation (BidirectionalIterator first, BidirectionalIterator last); template <c 阅读全文
posted @ 2021-05-13 16:05 刘大侠GG_B 阅读(47) 评论(0) 推荐(0)
摘要:将c++更改过的名字变回定义的名字 [root@lhx-node2 ~]# c++filt _Z3foob foo(bool) 读取二进制的文件 [lhx@lhx-master protobuf]$ od -A x -t x1z -v test 000000 0a 1e 0a 03 79 6c 6c 阅读全文
posted @ 2021-05-11 12:01 刘大侠GG_B 阅读(45) 评论(0) 推荐(0)
摘要:示例代码 #include <iostream> #include <memory> using namespace std; class base { public: ~base(){cout << "in ~base()" << endl;}; }; void fuc(base* pb) { c 阅读全文
posted @ 2021-04-21 13:44 刘大侠GG_B 阅读(93) 评论(0) 推荐(0)
摘要:share_ptr智能指针能够记录其实际的指向对象的类型,并正确的析构该对象。 所以使用share_ptr来管理的对象不需要虚析构函数 示例代码 #include <iostream> #include <memory> using namespace std; class base{ public 阅读全文
posted @ 2021-04-21 10:55 刘大侠GG_B 阅读(162) 评论(0) 推荐(0)
摘要:参考博客https://www.cnblogs.com/jiangzhaowei/p/4193283.html #include <signal.h> #include <errno.h> #include <pthread.h> #include <unistd.h> #include <sys/ 阅读全文
posted @ 2021-01-29 11:33 刘大侠GG_B 阅读(191) 评论(0) 推荐(0)
摘要:override var += -g #通过命令行传递的参数,不能覆盖var的值 sources = f1.c f2.c define hello @echo "test define" @echo "test define hello" endef test:foo $(call hello) # 阅读全文
posted @ 2021-01-28 15:42 刘大侠GG_B 阅读(98) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdarg.h> int foo(int flag, ...){ va_list ap; int value,test; if(flag == 1) { va_start(ap,flag); value=va_arg(ap,int); te 阅读全文
posted @ 2021-01-25 15:15 刘大侠GG_B 阅读(45) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 void (*p)(int); // <==>int a;变量的定义 3 void *f(int);//声明 4 5 void foo(int a) 6 { 7 printf("foo: %d\n", a); 8 } 9 10 int main() 11 阅读全文
posted @ 2021-01-21 15:37 刘大侠GG_B 阅读(69) 评论(0) 推荐(0)
摘要:C语言解析命令行参数getopt() 【转】getopt(分析命令行参数) 相关函数表头文件 #include<unistd.h> 定义函数 int getopt(int argc,char * const argv[ ],const char * optstring); 函数说明 getopt() 阅读全文
posted @ 2020-12-21 14:08 刘大侠GG_B 阅读(235) 评论(0) 推荐(0)
摘要:有效用户、组ID及其实际用户、组ID 代码 #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main(int argc, char* 阅读全文
posted @ 2020-09-23 11:40 刘大侠GG_B 阅读(298) 评论(0) 推荐(0)
摘要:##list.h /******* 链表实现,来自内核 **************************************************/ /** * container_of - cast a member of a structure out to the containin 阅读全文
posted @ 2020-06-11 13:40 刘大侠GG_B 阅读(329) 评论(0) 推荐(0)
摘要:#include "stdafx.h" #include using namespace std; class aa{ int num; public: aa(); void out1(){ cout<<num<<endl; } void out2() const{ cout<<num<<endl; 阅读全文
posted @ 2020-06-09 11:09 刘大侠GG_B 阅读(165) 评论(0) 推荐(0)
摘要:C语言宏中"#"和"##"的用法 在查看linux内核源码的过程中,遇到了许多宏,这里面有许多都涉及到"#"和"##",因此,在网上搜索了一些资料,整理如下:一、一般用法 我们使用#把宏参数变为一个字符串,用##把两个宏参数贴合在一起. 用法: #include<cstdio> #include<c 阅读全文
posted @ 2020-06-01 15:36 刘大侠GG_B 阅读(191) 评论(0) 推荐(0)
摘要:```c++using namespace std;class A{ private: static int a;//由static修饰的变量仅仅是一个声明,不能在此处进行初始化,需要在类的外部初始化。 void foo() { a = 1; ... 阅读全文
posted @ 2020-02-18 22:21 刘大侠GG_B 阅读(218) 评论(0) 推荐(0)
摘要:1 #include<iostream> 2 #include <stdio.h> 3 using namespace std; 4 class test{ 5 int mvalue; 6 public: 7 explicit test(int i=0){ //此处的explicit表明该构造函数需 阅读全文
posted @ 2019-11-18 17:02 刘大侠GG_B 阅读(247) 评论(0) 推荐(0)
摘要:C语言中的可变参数-printf的实现原理 在C/C++中,对函数参数的扫描是从后向前的。C/C++的函数参数是通过压入堆栈的方式来给函数传参数的(堆栈是一种先进后出的数据结构),最先压入的参数最后出来,在计算机的内存中,数据有2块,一块是堆,一块是栈(函数参数及局部变量在这里),而栈是从内存的高地 阅读全文
posted @ 2019-11-08 17:54 刘大侠GG_B 阅读(584) 评论(0) 推荐(0)
摘要:在了解/etc/ld.so.conf.d/目录下文件的作用之前,先介绍下程序运行是加载动态库的几种方法:第一种,通过ldconfig命令 ldconfig命令的用途, 主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下, 搜索出可共享的动 阅读全文
posted @ 2019-11-07 15:10 刘大侠GG_B 阅读(498) 评论(0) 推荐(0)

1