ifstream ifs(filename.c_str()); string s; while( ifs >> s) cout << s << "\n";解释一下是什么意思?

如题所述

ifstream ifs(filename.c_str()); // 用文件输入流读入文件名为filename这个文件
string s; // 定义string类对象
while( ifs >> s) // 循环在文件输入流中读入一个字符串
cout << s << "\n"; // 读入一个,打印一个,并打印换行
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-09-24
c_str()应该是字符串流的一种,可能是将文件里的字符串储存在ifs中,然后再打印出来
第2个回答  2012-09-23
你打错没
相似回答