![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
jlulxg
这个作者很懒,什么都没留下…
展开
-
C++ char*,const char*,string的相互转换
1. string转const char*string s ="abc";const char* c_s = s.c_str();2. const char*转string 直接赋值即可const char* c_s ="abc";string s(c_s); 3. string转char*string s ="abc";char* c;constint len...转载 2018-12-02 09:49:45 · 922 阅读 · 0 评论 -
C++去掉字符串中首尾空格和所有空格
//去掉首尾空格void trim(string &s) { if( !s.empty() ) { s.erase(0,s.find_first_not_of(" ")); s.erase(s.find_last_not_of(" ") + 1); } }//去掉所有空格void trim(stri...转载 2018-12-02 09:52:40 · 3780 阅读 · 1 评论 -
动态规划求最小编辑距离
//求最小编辑距离 int editDistance(const string source, const string target){ //step 1 int len_source = source.length(); int len_target = target.length(); if (len_source ...转载 2018-12-02 10:00:37 · 242 阅读 · 0 评论 -
c++11 智能指针 unique_ptr、shared_ptr与weak_ptr
原文地址:https://www.cnblogs.com/lsgxeva/p/7788061.htmlC++11中有unique_ptr、shared_ptr与weak_ptr等智能指针(smart pointer),定义在<memory>中。可以对动态资源进行管理,保证任何情况下,已构造的对象最终会销毁,即它的析构函数最终会被调用。 unique_ptruniqu...转载 2018-12-02 14:54:40 · 126 阅读 · 0 评论 -
gcc中的 -I -L(大写l) -l(小写l) -Wl,-rpath 选项
gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录:例子1:gcc -o example1 example1.c -I /usr/local/include/freetype2 -lfreetype -lm上面这句话在编译example1.c 时,-I /usr/local/include/freetype2 表示将/usr...转载 2018-12-31 11:45:21 · 1436 阅读 · 0 评论