
C&C++
风尘仆
这个作者很懒,什么都没留下…
展开
-
C++ set操作
set 中没有实现成员函数 at(),也没有实现 operator[]() 。除了这些操作外,set 容器提供 map 容器所提供的大部分操作。可以使用 insert()、emplace()、emplace_hint() 成员函数来向 set 中添加元素。原创 2021-03-28 21:06:11 · 355 阅读 · 0 评论 -
linux下ulimit设置
https://www.cnblogs.com/kevingrace/p/8243938.html原创 2021-01-06 20:35:05 · 179 阅读 · 0 评论 -
CMake编译时支持GDB调试
https://www.jianshu.com/p/801113ab1bfc原创 2021-01-02 02:09:43 · 150 阅读 · 0 评论 -
C 库函数 - atoi()
https://www.runoob.com/cprogramming/c-function-atoi.html转载 2020-12-24 09:54:27 · 153 阅读 · 0 评论 -
在win10环境下的VScode中使用Cmake
1.cmake -G "MinGW Makefiles" ..2.mingw32-make原创 2020-11-08 20:28:34 · 506 阅读 · 0 评论 -
结合cmake使用googletest
1.安装googletest 在https://github.com/google/googletest/releases下载源代码压缩包。 cd googletest mkdir build;cd build cmake -DBUILD_SHARED_LIBS=ON -Dgtest_build_samples=ON .. make make install2.验证安装是否成功cd build/googletest ./sample1_unittest 输出 Run ...原创 2020-10-14 23:43:13 · 892 阅读 · 0 评论 -
error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ a
注意输出流中不应该包含返回值为void的函数。https://stackoverflow.com/questions/53224411/error-no-match-for-operator-operand-types-are-stdostream-aka-stdbasi原创 2020-10-04 20:33:16 · 21689 阅读 · 1 评论 -
【C++知识】const关键字
1.在变量声明中使用const const int *const2 //const2是一个指针,指向了一个constint(常整形)变量 int const *const3 //与以上作用一致。const3是一个指针,指向了一个const int(常整形)变量 int *const const4 // const4是一个constpointer(指针常量)指向了一个整形变量 int const *const const5 // const5是一个指针常量指...原创 2020-10-03 14:03:48 · 212 阅读 · 0 评论 -
error while loading shared libraries
库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程序)时被使用,其搜索路径是在系统中进行设置的。一般Linux 系统把 /lib 和 /usr/lib两个目录作为默认的库搜索路径,所以使用这两个目录中的库时不需要进行设置搜索路径即可直接使用。对于处于默认库搜索路径之外的库,需要将库的位置添加到库的搜索路径之中。设置库文件的搜索路径有下列两种方式,可任选其一使用:1.修改环境变量LD_LIBRARY_PATH在环境变量 LD_LIBRARY_PATH 中指明库的搜索路径。2.修改配置文件ld转载 2020-09-11 11:29:33 · 478 阅读 · 0 评论 -
_GLIBCXX_USE_CXX11_ABI, GCC 4.8 and ABI compatibility
Dual ABIhttps://gcc.gnu.org/onlinedocs/gcc-5.2.0/libstdc++/manual/manual/using_dual_abi.htmlhttps://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/https://stackoverflow.com/questions/45417707/glibcxx-use-cxx11-abi-gcc-4-8-and-abi-compatib原创 2020-09-10 02:01:40 · 615 阅读 · 0 评论 -
Python3.6通过使用ctypes库调用自己编写的C++函数
1、编写C++头文件及源代码。2、使用cmake打包测试无问题。3、添加关键字“extern C”。有必要的话修改C++函数参数类型。4、编写python程序调用from ctypes import *infile = "./ball_vicon_09041823.txt".encode('utf-8')outfile = "./ball_vicon_fixed_09041825.txt".encode('utf-8')vdtpcs = cdll.LoadLibrary('./b原创 2020-09-09 23:46:00 · 506 阅读 · 0 评论 -
string to char* and char* to string 玩转 String 和 Char*
char 类型是c语言中常见的一个数据类型,string是c++中的一个,它的定义为Strings are objects that represent sequences of characters. 由此可见string是一个char序列的对象,有时候我们经常需要混用这两个数据类型,所以有些常见的错误还是需要避免的:比如,string的append函数只能加const char类型的,而push_back函数可以加char类型的,也可以直接用 += 来添加char类型的,如果要同时添加两个c..转载 2020-09-09 23:06:26 · 187 阅读 · 0 评论 -
C++传入命令行参数
参考:https://blog.youkuaiyun.com/qq_34719188/article/details/83788199https://www.man7.org/linux/man-pages/man3/getopt.3.html#include <getopt.h>#include <iostream>int num = -1;bool is_beep = false;float sigma = 2.034;std::string write_fi.原创 2020-09-06 02:42:56 · 1480 阅读 · 0 评论 -
VScode配置C++编译环境
ctrl+shift+p 修改插件配置ctril+shift+b 运行生成任务调试模式:F5 启动调试F9 加断点F10 单步跳过。运行至下一条执行语句,不进入函数F11 单步调试。F12 单步跳出ctrl+shift+F5 重启shift+F5 停止监视:可以对某个变量进行操作变量:可以显示本地变量参考:https://blog.youkuaiyun.com/liu_feng_zi_/article/details/102797866python调试:...原创 2020-09-04 22:44:39 · 232 阅读 · 0 评论 -
cmake中使用so库
cmake_minimum_required(VERSION 2.0)project(cmaketest)#头文件搜索路径include_directories("/home/frank/cvcode/slambook/ch2")#库文件搜索路径link_directories("/home/frank/cvcode/slambook/ch2/build" )add_executable(useHell useHell.cpp )target_link_libraries(..原创 2020-08-10 22:28:39 · 3277 阅读 · 0 评论 -
段错误(Segment Fault)
1.什么是段错误(Segmemt Fault)A segmentation fault (often shortened to segfault) is a particular error condition that can occur during the operation of computer software. In short, a segmentation fault occ...原创 2020-04-03 18:46:37 · 1168 阅读 · 0 评论 -
C语言练习题
第一题:8. 编写一个程序,将字符串Str2中的全部字符复制到字符串Str1中。要求:不能使用strcpy函数。(12分) #include //假设str2的长度不超过str1的长度void strcopy(char *str1,char *str2){ inti=0,j=0; while(str2[i])原创 2016-12-16 23:58:19 · 3384 阅读 · 3 评论 -
C++-string用法
1.string类成员函数find/find_first_of用法详解blog.youkuaiyun.com/iot_change/article/details/8496977转载 2017-02-17 13:00:01 · 417 阅读 · 0 评论 -
二维vector初始化
#include #include using namespace std;int main(){ int m=3,n=7; vector > results(m,vector(n,0)); for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cout<<results[i][j]<<'\原创 2017-04-09 20:35:33 · 2145 阅读 · 0 评论 -
程序的内存布局
进程的内存布局在C++中,内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量存储区。 栈,在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高,但是分配的内存容量有限。 堆,就是那些由new分配的内存块,他们的释放编译器不去管,由我们的应用程序去控制,一般一个new就要原创 2017-04-04 22:04:36 · 325 阅读 · 0 评论 -
在vector查找某元素
#include#include#includeusing namespacestd;vectorarray(100);//整型的array数组int main(){ array[20]=50; vector::iterators=find(array.begin(),array.end(),50);第一个参数是array的起始地址,第原创 2017-05-24 20:32:24 · 4330 阅读 · 0 评论 -
CPP_STL总结
Overview of the STLThe STL is logically divided into six pieces, each consisting of generic components that interoperate with the rest of the library:•Containers. At the heart of the STL原创 2017-05-25 14:09:28 · 517 阅读 · 1 评论 -
remove_if的使用
Removes all elements satisfying specific criteria from the range [first, last) and returns a past-the-end iterator for the new end of the range.1) Removes all elements that are equal tovalue.3原创 2017-05-26 14:41:59 · 556 阅读 · 0 评论 -
lower_bound的使用
unction templatestd::lower_bounddefault (1)template ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val);原创 2017-05-27 20:39:04 · 1705 阅读 · 0 评论 -
leetcode-303. Range Sum Query - Immutable
解题思路:求解区间内元素的和。由于要多次查询,最朴素的方法是每次查询依次遍历集合中的所有元素并求和。但显然多次查询区间有交叉的话会重复计算某些新元素。由于区间是连续的,考虑保存中间的结果。下次查询就节省了很多重复计算。实现代码:class NumArray {public: vector arr; NumArray(vector nums) {原创 2017-05-19 22:01:15 · 330 阅读 · 0 评论 -
leetcode-26. Remove Duplicates from Sorted Array
解题思路:首先考虑利用vector容器自身提供的erase方法。使用一个历史变量保存上一个浏览过的元素,当前访问元素与历史记录不同时向前移动指针否则删除指针。但这种方法效率较低。考虑换一种写法,可以不使用容器提供的方法,效率还可以更快。解题代码一:class Solution {public: int removeDuplicates(vector& nums原创 2017-06-12 22:54:39 · 255 阅读 · 0 评论 -
Vector容器删除元素
std::vector::erase C++ Containers library std::vector (1) iterator erase( iterator pos);(until C++11)iterator erase( const_iterator pos原创 2017-09-12 21:37:47 · 695 阅读 · 0 评论 -
C++--char * 与int的互转
1.c++ 中 char 与 string 之间的相互转换问题http://www.cnblogs.com/devilmaycry812839668/p/6353807.html原创 2017-11-04 00:13:09 · 6009 阅读 · 0 评论 -
C++保留小数位数
注意:1.只设置setprecision(n)意思是包含小数点前后所有数字的位数。2.在前一项前添加fixed关键字后可以设置小数点后有效数字的个数。引用(http://www.cnblogs.com/krisdy/archive/2009/04/17/1438402.html):“”“1. C++中格式控制 在C++中,说到保留小数点后几位有效数字,原创 2017-12-05 13:10:55 · 3041 阅读 · 0 评论 -
Cpp中使用getline读取一整行字符串
getline是在string头文件中定义的一个函数,以一个istream对象和一个string对象作为输入参数。该函数首先读取输入流的内容直到遇到换行符停止,然后将读入的数据存入string对象,最后返回istream对象。其中换行符读入但是不保留。#include #include using namespace std;int main(){ string buf;原创 2016-11-19 19:43:09 · 7692 阅读 · 0 评论