
C++
jun_zhu
use our heart to create value
展开
-
C++ string 数字加法
#include <iostream>#include <algorithm>#include <vector>using namespace std;string AddString(string strA,string strB){ reverse(strA.begin(),strA.end()); reverse(strB.begin(),strB.end()); int lenA = strA.length(); ..原创 2020-10-31 20:04:19 · 2018 阅读 · 0 评论 -
GZip解压
int UnCompress(const char * src, int len){ z_stream strm; strm.zalloc = NULL; strm.zfree = NULL; strm.opaque = NULL; strm.avail_in = len; strm.next_in = (Bytef *)src; int err = -1, ret = -1; err = inflateInit2(&strm,.原创 2020-05-12 15:50:25 · 278 阅读 · 0 评论 -
C++ utf-8和gbk互转
#include <iostream>#include <string>using namespace std;class chs_codecvt : public codecvt_byname<wchar_t, char, std::mbstate_t> {public: chs_codecvt(string s) : codecvt_by...原创 2020-03-11 14:59:23 · 1407 阅读 · 0 评论 -
Boost获取当前日期时间
#include <boost/timer.hpp>#include <boost/progress.hpp>#include <boost/date_time/gregorian/gregorian.hpp>#include <boost/date_time/posix_time/posix_time.hpp>#include <b...原创 2020-02-13 16:57:17 · 2253 阅读 · 0 评论 -
Boost.Python的简单使用
Python调C函数C端定义char const * hello(){ return "hello,world";}BOOST_PYTHON_MODULE(hello){ def("hello", hello);}python端调用import helloprint hello.hello()Python中//用于线程安全class ...原创 2018-09-04 10:36:14 · 993 阅读 · 0 评论 -
使用C API 实现C调Python 和python调C
Python调Cpython 调C语言主要是将C代码编译成so文件,通过python端的ctypes导入C库使用C函数,简单使用如下void TestLib::hello(int a) { printf("hello world");}extern "C" { void hello();}python 端import ctypesso = ctypes.c...原创 2018-11-16 14:00:34 · 1387 阅读 · 0 评论 -
C++11 string新特性
在使用字符串时不可避免的经常用到转义字符\,今天看了C++标准库,看到了string 的新特性,可以不再使用转义字符,如下:string data = "what\' your name";string data = R"(what' your name)";在使用()时需注意:R"delim(what' your name)delim",delim是字符序列,不得超过16个字符。...原创 2019-07-29 13:22:52 · 392 阅读 · 0 评论