设为首页 加入收藏

TOP

C++从纯文本中读取字符串(string)内容
2014-11-24 07:46:09 来源: 作者: 【 】 浏览:1
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)工程举例

评论

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

·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)
·Redis配置中`require (2025-12-26 03:18:58)
·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)