getline

Hi,
Im experiencing a strange problem, I was developping on linux using g++ and I couldnt believe there was an error in my code. I then compiled my program with VC++ and there is no problem pffff.
Here is my code:

1
2
3
4
ifstream myFile(fileName.c_str());
while(getline(myFile,line)){
    cout << "line read:*" << line<<"*" << endl;
}


with G++ I have segmentation fault at the end of the while on the getline.

where this problem come from ?
thanks
Assuming that "line" is a std::string, you don't do any evil things with #defines and everything here is the stuff from namespace std, then it should work in GCC.

Can you post the whole code for GCC that give the segfault?

Ciao, Imi.
Topic archived. No new replies allowed.