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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -