现在的位置: 首页 > 综合 > 正文

46、string类的push_back的应用-按字符存储数据

2011年11月24日 ⁄ 综合 ⁄ 共 228字 ⁄ 字号 评论关闭

string类的push_back的应用-按字符存储数据

示例

View Code

#include <iostream>
#include
<fstream>
#include
<string>
using namespace std;

int main ()
{
string str;
ifstream file(
"F:\\log.txt",ios::in);
while (!file.eof())
{
str.push_back(file.
get());
}
cout
<< str;
return 0;
}

抱歉!评论已关闭.