设为首页 加入收藏

TOP

C++从纯文本中读取字符串(string)内容
2014-11-24 07:46:09 来源: 作者: 【 】 浏览:0
Tags:从纯 文本 读取 字符串 string 内容

C++从纯文本中读取字符串(string)内容


void demo::fr()
{
// read string from text file
ifstream fin;
fin.open("sample.in");
ifstream fin_result;
fin_result.open("sample.out");


string line;
string line_result;
int no=0;
if(NULL!=getline(fin,line))
{
cout<<"line no="< }
while(getline(fin,line)&&getline(fin_result,line_result))
{
cout<<"no"< line_result = line_result.substr(9); // read the content from the 9 position
cout<<"no"< }
string ss("god!"); // show the length of string ss
cout<<"no="< fin.close();
fin_result.close();
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇matlab中semilogx画图和显示error.. 下一篇Dev-C++创建使用类(Class)工程举例

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)