
c++工具类小程序
map-link
这个作者很懒,什么都没留下…
展开
-
c++ trim类,去掉空格
std::string trim(std::string& str) { if(str.empty()) return std::string(); size_t s,e; for(s =0; s < str.length();s++){ if(!isspace(str.at(s))) break; } for(e = str.length()-1; ...原创 2018-08-01 15:11:42 · 827 阅读 · 0 评论 -
c++ split工具类,切分字符
void split(const std::string& s, const std::string& delim, std::vector<std::string> &ret) { size_t last = 0; size_t index=s.find_first_of(delim,last); ret.clear(); w...原创 2018-08-01 15:23:14 · 124 阅读 · 0 评论 -
c++ 大小写转换类
void to_upper(std::string &str) { for(std::string::iterator it = str.begin(); it != str.end(); it++) *it = toupper(*it); } void to_lower(std::string &str) { for(std::string::...原创 2018-08-01 15:25:23 · 849 阅读 · 0 评论 -
获取毫秒时间戳
unsigned long clockGetTimeHaoMiao() { struct timespec stv; clock_gettime(CLOCK_MONOTONIC, &stv); unsigned long haoMiao = stv.tv_sec * 1000 + stv.tv_nsec /1000000; return haoMiao; ...原创 2018-08-10 15:54:36 · 798 阅读 · 0 评论 -
获取本地ip地址信息
#include<stdio.h> #include <sys/ioctl.h> #include<netinet/in.h> #include<net/if.h> #include <arpa/inet.h> #include <sys/socket.h> #include <unistd.h> #includ原创 2018-08-17 15:18:04 · 192 阅读 · 0 评论 -
获取系统毫秒时间的两种方法
unsigned long clockGetTimeHaoMiao2() { struct timespec stv; clock_gettime(CLOCK_MONOTONIC, &stv); unsigned longt haoMiao = stv.tv_sec * 1000 + stv.tv_nsec /1000000; return haoMiao...原创 2018-08-17 15:23:56 · 3035 阅读 · 0 评论 -
获取本地IP
inline uint32_t getLocalIP() { int sock_fd; struct ifreq buf[16]; struct ifconf ifc; uint32_t interface_num; uint32_t loIp = inet_addr("127.0.0.1"); uint32_t localIp = 0; if((sock_fd = ...原创 2018-08-24 10:05:15 · 227 阅读 · 0 评论