Author Topic: Missing ifstream and ofstream  (Read 17102 times)

Offline Maulrus

  • Single posting newcomer
  • *
  • Posts: 4
Missing ifstream and ofstream
« on: June 03, 2010, 03:03:03 am »
I just installed Code::Blocks 10.5 with MinGW. I'm compiling a project when it gives me an error: ifstream: No such file or directory. I get the same error for ofstream. I go into the include folders and, to my surprise, they're not there! Everything else seems to be, including fstream, is in there. What happened, and where can I get these headers?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Missing ifstream and ofstream
« Reply #1 on: June 03, 2010, 04:31:40 am »
It should work ok.
Post your full build log.
Post your code, then others can test for you.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Maulrus

  • Single posting newcomer
  • *
  • Posts: 4
Re: Missing ifstream and ofstream
« Reply #2 on: June 03, 2010, 04:56:30 am »
Build log:

Quote
Compiling: C:\CodeBlocks\Exercises\test.cpp
C:\CodeBlocks\Exercises\test.cpp:1:20: error: ifstream: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

Code:

Code
#include <ifstream>

int main(){}

This wasn't the code that I had the problem with originally, but it still gives me the same error.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Missing ifstream and ofstream
« Reply #3 on: June 03, 2010, 05:04:12 am »
ifstream - C++ Reference

BTW: this question is totally unrelated to Codeblock, so, it violate the forum rule!!!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Maulrus

  • Single posting newcomer
  • *
  • Posts: 4
Re: Missing ifstream and ofstream
« Reply #4 on: June 03, 2010, 05:10:30 am »
That link doesn't really help me at all.

I posted it here because I installed MinGW from the C::B installer, which led to me to believe the problem had something to do with C::B. I apologize if this is actually the wrong forum for it.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Missing ifstream and ofstream
« Reply #5 on: June 03, 2010, 05:17:55 am »
No, please reread the link carefully, the ifstream class is declared in fstream .

BTW: My last post in this thread.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Maulrus

  • Single posting newcomer
  • *
  • Posts: 4
Re: Missing ifstream and ofstream
« Reply #6 on: June 03, 2010, 05:20:25 am »
Wow I am a dumbass.

Sorry for refusing your help earlier, this can be deleted or closed or whatever.