
C++标准库/Boost
几百人在爱
这个作者很懒,什么都没留下…
展开
-
fstream如何打开中文路径 - [C/C++]
<br />版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明<br />http://yzyanchao.blogbus.com/logs/35621328.html<br /><br /> VS2005开始(似乎),用ofstream打开中文路径名会出现乱码问题,解决方法为:<br />std::locale loc = std::locale::global(std::locale(""));<br />std::ofstream fout(FilePath);<br />//转载 2011-05-19 14:15:00 · 1887 阅读 · 1 评论 -
boost format 格式控制输出(学习笔记)
<br />#include <boost/format.hpp>#include <iostream>using namespace boost;using namespace std;// 格式输出控制,(类似c++准准库中的sprintf)// int main(){ // format库的几种用法 //------------------------------------------ // 第一种: // 最接近printf() cout<< "原创 2011-01-28 23:39:00 · 1525 阅读 · 0 评论 -
boost SHA1学习笔记
#include #include /* @brief SHA1摘要算法:一种很重要的密码学算算法,要将任意长度的文本压缩成20个字节的 独一无二的的摘要(uuid名字生成器使用的算法)*/using namespace boost::uuids::detail;using namespace std;int main(){ sha1 sha; // 声明摘要对象 char* szMsg = "This is a short message!"; //原创 2011-01-25 21:18:00 · 7710 阅读 · 0 评论 -
boost lexical_cast 字符串数字间的字面转换(学习笔记)
#include /* @brief 实现数字和字符串之间的字面转换 如把123(int)转换成"123"(string) @remark 注意:要转换为数字的字符串不能包含数字、小数点和e/E以外的字符 如:0x100,123L等C++允许的字面数字都不被支持*/using namespace boost;int main(){ //-------------------- // 字符串字面转成数字 //-------------------- int原创 2011-01-25 22:46:00 · 10664 阅读 · 0 评论 -
boost uuid 学习笔记
<br />#include <vector>#include <iostream>#include <boost/uuid/uuid.hpp>#include <boost/uuid/uuid_generators.hpp>#include <boost/uuid/uuid_io.hpp>using namespace boost::uuids;using namespace std;int main(){ //------------------------- /原创 2011-01-25 01:28:00 · 5968 阅读 · 1 评论 -
boost exception 学习笔记
#include #include #include using namespace std;// 从std和boost,新的导常类就同时有它们两的能力 struct both_exception: virtual boost::exception, // 这里要用虚继承 virtual std::exception{};// 定义异常both_exception内部异常信息的数据类型// 这样异常信息就可以是各种类型typedef boost::er原创 2011-01-21 22:32:00 · 4590 阅读 · 1 评论 -
boost.property_tree使用示例
下面是一个使用boost.property_tree来解析XML/INI文件的简单示例。使用boost.property_tree来作为配置文件的解析工具非常合适.#include #include #include #include #include #include #include #include #include #include #include #include int main( int argc , char *argv[] ){转载 2011-05-10 14:06:00 · 4002 阅读 · 0 评论 -
c++文件复制
<br />转帖,转帖位置忘了<br />使用C++标准程序库的输入输出流(I/O Stream)复制文件,存在许多的方法,<br /><br />方法一:逐个字符复制<br /><br />#include < fstream ><br /><br />std::ifstream input("in",ios::binary);<br />std::ofstream output("out",ios::binary);<br />char ch;<br /><br />while (i转载 2011-05-18 21:34:00 · 895 阅读 · 0 评论 -
std::ifstream 打开文件,获得文件流 并赋给std::string
<br /> // 打开文件,获得文件流<br /> std::ifstream inFile(fileName.c_str(), std::ios::in | std::ios::binary);<br /> std::ostringstream oss;<br /> oss << inFile.rdbuf();<br /> std::string buffer = oss.str();<br /> inFile.close();原创 2011-05-20 18:32:00 · 6557 阅读 · 0 评论 -
lexicographical_compare()按字典序比较函数用法示例(字符串排序)
#include "algostuff.hpp"using namespace std;void printCollection(const list& l){ PRINT_ELEMENTS(l);}bool lessForCollection(const list& l1,const list& l2){ return lexicographical_compare(l1.begin(),l1.end(),l2.begin(),l2.end());}int m转载 2011-01-24 00:05:00 · 1576 阅读 · 0 评论