c++ - File I/O error with getline() -


my code:

void listall() {     string line;     ifstream input;     input.open("registry.txt", ios::in);      if(input.is_open())     {         while(std::getline(input, line, "\n"))         {             cout<<line<<"\n";         }     }     else     {         cout<<"error opening file.\n";     } } 

i’m new c++, , want print out text file line-by-line. i’m using code::blocks.

the error gives me is:

error: no matching function call 'getline(std::ifstream&, std::string&, const char [2])'

these valid overloads std::getline:

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); 

i'm sure meant std::getline(input, line, '\n')

"\n" not character, it's array of characters size of 2 (1 '\n' , nul-terminator '\0').


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -