Get an istream from a char*
来源:互联网 发布:达内python视频下载 编辑:程序博客网 时间:2024/05/24 01:01
#include <iostream>#include <istream>#include <streambuf>#include <string>struct membuf : std::streambuf{ membuf(char* begin, char* end) { this->setg(begin, begin, end); }};int main(){ char buffer[] = "I'm a buffer with embedded nulls\0and line\n feeds"; membuf sbuf(buffer, buffer + sizeof(buffer)); std::istream in(&sbuf); std::string line; while (std::getline(in, line)) { std::cout << "line: " << line << "\n"; } return 0;}
Which outputs:
line: I'm a buffer with embedded nullsand lineline: feeds
1 0
- Get an istream from a char*
- How to get an X11 Window from a Process ID?
- HOWTO: Get the project flavor (subtype) of a Visual Studio project from an add-in
- Get ip address from an interface name
- std::istream::get的误用
- C++ istream get() ostream::put()
- Populating an array from a query
- Select an option from a GXT ComboBox
- from-an-architect-to-a-programmer
- From an architect to a programmer
- 《From an architect to a programmer 》
- From an architect to a programmer
- Capturing an Image from a window
- Getting a Result from an Activity
- 18Getting a Result from an Activity
- Getting a Result from an Activity
- Getting a Result from an Activity
- An abandoned sentiment from past 814A
- Connecting with Wi-Fi Direct
- 单例模式
- 【工具学习】——教你读懂Maven的配置文件
- 第十三周项目5—拓扑排序算法的验证
- JSON 之JAVA 解析
- Get an istream from a char*
- DIV CSS网站布局八个小技巧
- 第十五周实践项目1—验证算法(3)希尔排序
- POI - generate xls file
- Json数据的解析_Gson
- 【第15周-项目2-1 ——用哈希法组织关键字(处理冲突的方法采用线性探测法)】
- 《华夏魂1》:全世界怎都喜欢中国先秦人
- 蓝牙的漏洞、威胁与对策
- android SQLiteOpenHelper使用示例