![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
花山主人
嚯嚯嚯
展开
-
C++备忘录(4) 代码中使用环境变量
使用getenv可以得到指定的环境变量假设我们在linux中定义了一个环境变量vim ~/.bashrcexport HOME="aaaaaa" source ~/.bashrc然后在C++程序中调用getenv函数,即可直接获取这个变量的值getenv("HOME")原创 2021-05-19 10:25:58 · 196 阅读 · 0 评论 -
C++通用makefile文件
#创建bin目录用来存放可执行程序TAG_DIR = ./bin$(shell mkdir -p ${TAG_DIR})#将当前路径和src目录下的所有cpp文件包含SRC = $(wildcard .cpp) $(wildcard src/.cpp)DIR=$(notdir (SRC))OBJ=(SRC))OBJ=(SRC))OBJ=(patsubst %.cpp, %.o, KaTeX parse error: Expected 'EOF', got '#' at position 8: (原创 2021-05-11 12:20:51 · 205 阅读 · 0 评论 -
Qtcreator vs2019 项目用git管理 win10系统
环境:Qtcreator5, win10安装git bash , 然后生成公钥添加进git管理平台(github, gitee等),我们这里用gitee。通过Qtcreator创建项目。用git bash进入此项目的跟目录。执行命令 git init git add . git commmit "create project" git remote add origin git@gitee.com:jarven-zhang/pss_client.git git p原创 2021-04-12 14:34:44 · 202 阅读 · 0 评论 -
c++11 多线程编程(1)多线程同步
通过互斥锁和条件变量实现线程同步例题:交替打印ABCDEABCDE…代码:#include <iostream>#include <future>#include <thread>#include <unistd.h>#include <mutex> using namespace std; mutex mx; //互斥锁condition_variable cv; //条件变量int flag = 0;//全局变量i原创 2021-01-19 09:40:41 · 234 阅读 · 0 评论 -
C++备忘录(2)地址运算
运行环境:cc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 64位机器首先看一段代码{ const char *p1 = "hello"; const char *p2 = "hello";原创 2021-01-05 23:21:51 · 420 阅读 · 0 评论 -
C++备忘录(1)自增运算符
C printf函数初识printf有意思的代码段初识printfprintf函数太普通了,是谁都会用的c语言输出函数。我们的Hello world就是通过调用它来实现的。一般的用法如下:const char * srcStr = "Hello world!";printf("%s\n", srcStr); %s ----- 打印字符串 %d ----- 打印int %f ----- 打印float有意思的代码段{ int i = 0;原创 2020-07-18 15:56:23 · 137 阅读 · 0 评论 -
关于C++11的Lambda函数
参考:https://blog.csdn.net/lixiaogang_theanswer/article/details/80905445基本定义[capture](parameters) mutable ->return-type{statement}最简单的lambda函数#include <iostream> using namespace std; i...原创 2019-07-03 14:27:57 · 87 阅读 · 0 评论 -
排序算法的C++实现----快速排序
int printArray(int a[], int len){ for(int p = 0; p < len; p++) { cout << a[p] << " "; } cout << endl;}int exchange(int& a, int& b){ a = a ...原创 2019-04-26 22:58:08 · 99 阅读 · 0 评论 -
C++单链表操作:节点的插入、删除、链表的转置
#include &lt;iostream&gt;using namespace std;struct node{ int data; node* next;};//插入一个节点,其实也是创建链表的意思int createrChain(node*&amp; head, int data){ node *new_one = new node; n...原创 2019-03-03 17:20:29 · 1161 阅读 · 0 评论 -
qtcreator的C++ pro文件配置
TEMPLATE = appDESTDIR = ./bin/ #指定路径TARGET= service #生成的可执行文件名称CONFIG += console c++11CONFIG -= app_bundleCONFIG -= qtSOURCES += main.cppHEADERS += Handler.hLIBS += -lglog #链接库...原创 2019-01-02 14:43:54 · 1682 阅读 · 0 评论