【发布时间】:2013-05-13 00:41:54
【问题描述】:
部分代码:
string name;
cin >> name;
ifstream userFile( name + ".txt");
if (userFile.good()){
// read away
cout << "Password? \n";
string pw;
cin >> pw;
//checking if pw matches
getline(userFile, 1);
所以我使用命名空间 std 并包含 sstream 字符串 fstream iostream。 它说参数类型是 (std::ifstream, int) 那么我在这里做错了什么?
编辑: 我认为第二个参数是指您要阅读的那一行。谁能向我解释一下我如何选择我可以以不同方式阅读的行?
【问题讨论】:
-
您是否包含
#include <iostream>和#include <string>? -
1应该做什么? -
getline具有签名istream& getline (istream& is, string& str);。没有将int作为第二个参数的重载。 -
umm...读完后你想把这行放在哪里?