您的位置:程序门 -> c/c++ -> c++ 语言



std::ifstream::getline的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


std::ifstream::getline的问题[已结贴,结贴人:coderlee]
发表于:2008-01-22 09:58:09 楼主
getline,read这两个函数都是传入一个char*进去,非常不方便,为什么不能直接传入std::string进去呢?

大家一般都怎么读取文件内容?想知道一个普遍的做法。

还有就是std::ofstream::clear是什么意思,是不是清除文件内容?   好像不起作用

另外std::ofstream::flush方法在什么时候使用
发表于:2008-01-22 10:01:111楼 得分:0
用getline(is,   str);版本
ostrem的clear()/flush()基本没有用处。
发表于:2008-01-22 10:02:382楼 得分:0
getline(is,   str);
这个是属于哪个类的方法
发表于:2008-01-22 10:03:283楼 得分:20
std里的全局函数
发表于:2008-01-22 10:05:354楼 得分:0
ok   明白了
c/c++ code
fstream hfile; hfile.open("c:\\1.txt", ios::out | ios::in, _sh_denywr); //only deny write string str; while(std::getline(hfile, str)) cout << str << endl; hfile.close();


快速检索

最新资讯
热门点击