std has no member 'getline'?

std::getline is defined in the string header.

#include <string>

Also, your code isn't using anything from cstring, cstdio, cmath, or cstdlib; why bother including these?

EDIT: To clarify the confusion regarding the cstring and string headers, cstring pulls the contents of the C runtime library's string.h into the std namespace; string is part of the C++ standard library and contains getline, std::basic_string<> (and its specializations std::string and std::wstring), etc. -- two very different headers.


As ildjarn points out, the function is declared in <string>, and I'm suprised you didn't get an error at:

string line;

Also, this:

 while(ifile.good()){
      getline(ifile,line);
 }

is not the way to write a read loop. You MUST test the success of the read operation, not the current stream state. You want:

while( getline(ifile,line) ) {
}

Tags:

C++

Io

Std

Getline