随笔分类 -  C/C++

摘要:bool srvPortIsUsed(int devPort) { string str_dev = std::to_string(devPort)+".txt"; std::strstream srm; //srm netstat.txt"; srm " << str_dev; system(srm.str()); //std::ifstream in("netstat.txt"); std:... 阅读全文

posted @ 2018-04-23 10:49 yacbo 阅读(258) 评论(0) 推荐(0) |

摘要:字符串切割的使用频率还是挺高的,string本身没有提供切割的方法,但可以使用stl提供的封装进行实现或者通过c函数strtok()函数实现。 1、通过stl实现 涉及到string类的两个函数find和substr: 1、find函数 原型:size_t find ( const string& 阅读全文

posted @ 2018-04-15 19:08 yacbo 阅读(774) 评论(0) 推荐(0) |

摘要:int Oper(int (*MyPointerFuncAdd)(int a,int b)) { int c=MyPointerFuncAdd(5,6);//间接调用 } int Oper(int (*MyPointerFuncAdd)(int a,int b)) { int c=MyPointer 阅读全文

posted @ 2018-04-11 16:48 yacbo 阅读(160) 评论(0) 推荐(0) |

摘要:1.属性->C++编译器->包含目录 (填写ffmpeg头文件所在的路径,本demo为本地的路径是include) 2.属性->链接器->其他库目录 (填写ffmpeg库所在的路径,本demo为本地的路径是lib) 3.属性->链接器->库 添加动态文件 /usr/local/lib/libavco 阅读全文

posted @ 2018-04-04 14:05 yacbo 阅读(155) 评论(0) 推荐(0) |

摘要:#include #include #include #include #include #include //包含有uint、uchar等 #include #include using namespace std; 1.定义也是声明,extern声明不是定义,即不分配存储空间。extern告诉编译器变量在其他地方定义了。 eg:extern int a; //声明,不是... 阅读全文

posted @ 2018-03-29 22:23 yacbo 阅读(161) 评论(0) 推荐(0) |

摘要:char* readFileBytes(const char *name, size_t *len) { ifstream fl(name); fl.seekg(0, ios::end); *len = fl.tellg(); char *ret = new char[*len]; fl.seekg(0, ios::beg); fl.read(re... 阅读全文

posted @ 2018-03-29 22:08 yacbo 阅读(484) 评论(0) 推荐(0) |

摘要:C++中int、string等常见类型转换 1、int型与string型的互相转换 #include <string>#include <cstring>#include <iostream>#include <stdio.h>#include <stdlib.h>#include <sstream 阅读全文

posted @ 2018-03-27 19:44 yacbo 阅读(368) 评论(0) 推荐(0) |

摘要:unsigned char buff1[128]={'a','b','c','d','e','f'}; //数组初始化前6位,后面默认为0 unsigned char buff2[128]={}; //数组初始化默认为0,创建数组必须初始化 memcpy(buff2,buff1+2,3); //将数组buff1内容拷贝到buff2中,buff1中第2位(0位、1位)开始的后... 阅读全文

posted @ 2018-03-23 09:02 yacbo 阅读(378) 评论(0) 推荐(0) |

摘要:#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include using namespace std; void main() { printf("hello ... \n"); string aa = to_string(10); cout << aa << en... 阅读全文

posted @ 2018-03-05 22:41 yacbo 阅读(216) 评论(0) 推荐(0) |

摘要:这个函数在socket中多用于清空数组.如:原型是memset(buffer, 0, sizeof(buffer)) 阅读全文

posted @ 2018-03-05 14:00 yacbo 阅读(846) 评论(0) 推荐(0) |

摘要: 阅读全文

posted @ 2018-03-01 16:08 yacbo 阅读(1474) 评论(0) 推荐(0) |

摘要:1. 截取子串 s.substr(pos, n) 截取s中从pos开始(包括0)的n个字符的子串,并返回 s.substr(pos) 截取s中从从pos开始(包括0)到末尾的所有字符的子串,并返回 2. 替换子串 s.replace(pos, n, s1) 用s1替换s中从pos开始(包括0)的n个 阅读全文

posted @ 2018-02-06 15:21 yacbo 阅读(254) 评论(0) 推荐(0) |

摘要://清空相机表数据. vector::iterator iter = vec_equip_camera.begin(); for (; iter != vec_equip_camera.end();) { delete *iter; iter = vec_equip_camera.erase(iter); } for (auto it = vec_files.begin(); it ... 阅读全文

posted @ 2018-01-03 09:35 yacbo 阅读(201) 评论(0) 推荐(0) |

摘要:#pragma pack(1)struct CBR{ unsigned int ip_addr; unsigned short port; unsigned short type; unsigned short length; unsigned int src; unsigned int dest; int itemsToSend; ... 阅读全文

posted @ 2017-11-27 15:07 yacbo 阅读(487) 评论(0) 推荐(0) |

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3