Jul 16, 2008 at 6:28pm
I am trying to run the following code (picked up from one of the examples on this site) on a windows m/c using the eclipse IDE.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("C:\\Documents and Settings\\examplefstream.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
but i get an error "error: no matching function for call to `getline(std::ifstream&, std::string*&)'" while tryin to build this code.
any ideas why?
PS: i am new to c++, this is my first program using files.
Jul 16, 2008 at 7:15pm
That compiles fine for me.
Windows XP, Eclipse Ganymede and MingW-GCC 3.9.5.
Jul 16, 2008 at 8:27pm
Works for me, MinGW-GCC 4.3.
Did you just recently install the compiler, or did you update it from something you had before?
Last edited on Jul 16, 2008 at 8:27pm
Jul 17, 2008 at 11:28am
when i reopened eclipse it is compiling fine for me too!! sorry for the trouble!! thanks anywayz.
Jul 17, 2008 at 11:34am
it could be bcus i hadnt saved the file, bcus i remember saving it while exiting eclipse. gosh!! feel so stupid!! sorry again..