0

So I have this very basic code that should work, however, I keep getting two errors:

1. Method 'open' could not be resolved. 2. Method 'close' could not be resolved. 

I'm new to C++, but I've seen this used tons of other places, but yet its not working for me. Would someone please explain to me what exactly is going on? Here is the code:

#include <iostream> #include <fstream> using namespace std; int main() { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0; } 

I have a similar, longer program I'm working with and the something is occurring. Thanks!

6
  • Runs fine here. Commented Nov 25, 2015 at 3:05
  • How are you compiling? Are you using any particular IDE? Commented Nov 25, 2015 at 3:07
  • Oh, sorry. I'm using Eclipse Mars. Commented Nov 25, 2015 at 3:08
  • Ok, so if its working fine for you then it must be something wrong with the IDE. Commented Nov 25, 2015 at 3:09
  • It's odd but I got it to work by closing Eclipse and reopening. Commented Nov 25, 2015 at 3:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.