c++ - "No instance of overloaded function 'getline'.." -
part of code:
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);
so using namespace std , include sstream string fstream iostream. says argumented types (std::ifstream, int) doing wrong here?
edit: thought 2nd parameter referred line you'd read. explain me how select line can read in different way?
quoting std::istream::getline, not have prototype takes ifstream
object , size_t
.
istream& getline (char* s, streamsize n ); istream& getline (char* s, streamsize n, char delim );
also quoting std::getline (string),it has following:
istream& getline (istream& is, string& str, char delim);
istream& getline (istream&& is, string& str, char delim);
istream& getline (istream& is, string& str);
istream& getline (istream&& is, string& str);
you using getline
in wrong way. if trying use getline
read lines file, can try following:
string currline; getline(userfile, currline); //do current line
Comments
Post a Comment