0

I am having trouble using fstream in a very simple code here it is :

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
string line;
fstream file;

file.open("taches.txt", ios::in);


return 0;
}

Problem is Eclipse is giving Method 'open' could not be resolved but since I included fstreams and iostream I am baffle. Can soemone point out what I am doing wrong?

MrTux
  • 32,350
  • 30
  • 109
  • 146
Sebastien
  • 1,308
  • 2
  • 15
  • 39
  • If it could help I ma on linuxmint 16 using linux gcc – Sebastien Oct 05 '14 at 22:04
  • This works for me fine using gcc 4.7.4. EDIT: Okay, I can compile it either way. I think your problem might be in Eclipse. What version of gcc do you have? – kiss-o-matic Oct 05 '14 at 22:06
  • There's nothing wrong with the code (it is actually C++11-compatible). Try fstream file ("taches.txt", ios::in); as workaround. – Sceptical Jule Oct 05 '14 at 22:08
  • 1
    Not necessarily (and I'd assume probably not). In a terminal, type gcc --version and report the output. That's a start at least. Second would be the entire error output that you see in Eclipse. – kiss-o-matic Oct 05 '14 at 22:09
  • gcc --version gives me 4.8.1 as for the entire Eclipse error thats about it. – Sebastien Oct 05 '14 at 22:12
  • Never mind I saved close/reopen Eclipse and the error is gone all is fine thank you every one. – Sebastien Oct 05 '14 at 22:17

0 Answers0