
C++
JSON_ZJS
热爱生活,热爱编程。
展开
-
C++字符串分割替换 ubuntu版本
#include <iostream> #include <string> #include <vector> using namespace std; vector<string> mySplit(const string& str,string sp_string) // split(),str 是要分割的str...原创 2020-04-28 10:06:32 · 335 阅读 · 0 评论 -
C++将字符串写入到文件中 覆盖或者不覆盖
#include <fstream>#include <iostream>#include <sstream>#include <string>using namespace std;string gettime() { time_t rawtime; struct tm *ptminfo; ...原创 2019-10-24 13:47:52 · 4721 阅读 · 0 评论 -
C++比较两个字符串是否完全相同
在写程序的过程中,经常会遇到要比较两个字符串是否相等的情况。如果要比较的对象是char字符串,则利用int strcmp(const char s1,const char* s2)当s1 < s2时,返回为负数;当s1 == s2时,返回值= 0;当s1 > s2时,返回正数。即:两个字符串自左向右逐个字符相比(按ASCII值大小相比较),直到出现不同的字符或遇’\0’为止。...原创 2019-10-24 10:41:23 · 6838 阅读 · 0 评论 -
c++生成不重复的随机整数
#include "stdafx.h"#include <iostream> #include <vector>#include <stdlib.h> #include <time.h>#include<list>using namespace std;int _tmain(int argc, _TCHAR* argv[])...原创 2019-10-17 15:54:45 · 722 阅读 · 0 评论 -
ubuntu下inotifywait实现目录、文件监控【包含子目录】
inotifywait命令【命令格式】: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ … ]【命令原意】: inote file system wait【命令路径】:【命令功能】: 等待所监听的文件系统触发操作事件【执行权限】: root【命令描述】:众所周知,Linux 桌面系统与 MAC 或 Windows 相比有许多不...原创 2019-09-29 17:21:51 · 2493 阅读 · 0 评论 -
ubuntu 16.4 安装postgreSQL,使C++链接到数据库
1、安装postgreSQL Ubuntu下编译安装postgreSQL 10.5https://blog.csdn.net/lc_2014c/article/details/841891622、安装驱动Libpqxx下载编译报错安装sudo apt-get install libpq-dev3.设置数据库允许远程登录ubuntu设置postgresql允许被远程访问https:/...原创 2019-09-29 09:46:37 · 386 阅读 · 0 评论 -
c/c++ 字符串分割
c/c++ 字符串分割vector<string> split_string(const char *str, const char *pattern){ char * strc =(char*)str; vector<string> res; char* temp = strtok(strc, pattern); while(temp...原创 2019-08-29 13:46:39 · 512 阅读 · 0 评论 -
Ubuntu C++ Thread Sleep
#include #include <unistd.h>using namespace std;int main() {cout << “nitrate”;cout << flush;usleep(1000000);cout << “firtilizers”;return 0;}原创 2019-08-28 11:40:18 · 1805 阅读 · 0 评论 -
Ubuntu C++代码获取系统时间
#include <iostream>#include <time.h>using namespace std;int main() { time_t tt; time( &tt ); tt = tt + 8*3600; // transform the time zone tm* t= gmtime( &tt ...原创 2019-08-21 09:09:00 · 1135 阅读 · 0 评论 -
C++实现字符串的拼接
#include #include using namespace std;int main(){//字符创的拼接string a = “rtmp://192.168.0.128:1935/live/Test”;string b = “.flv”;a.append(b);cout<<a<<endl;string str;str.assign(a); //...原创 2019-07-10 11:49:49 · 1118 阅读 · 0 评论