Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: PetruD on November 17, 2011, 12:06:51 am

Title: #include file not found
Post by: PetruD on November 17, 2011, 12:06:51 am
I've opened a .cpp file with C::B without inserting it in a project and when I tried to compile it, I got "fstream.h : no such file or directory". Am I missing something? Thank you in advance.
Title: Re: #include file not found
Post by: oBFusCATed on November 17, 2011, 07:29:40 am
Yes, a modern book to teach you modern c++ :)
Title: Re: #include file not found
Post by: zabzonk on November 17, 2011, 10:49:20 am
The header fstream.h is part of C++ from long, long ago before the language was standardised (which happened in 1998). You should not be using it in your code, and you should not be using learning resources that suggest you do use it. The header file you want is fstream, used as:

Code
#include <fstream>
Title: Re: #include file not found
Post by: PetruD on November 17, 2011, 04:26:10 pm
I am bound to use it in my code. I'm participating in an olympiad, and I am only allowed to use this particular header, or maybe stdio in my code.
Title: Re: #include file not found
Post by: zabzonk on November 17, 2011, 04:36:31 pm
Well, it is an "olympiad" run by clueless, know-nothing chumps then. That header is not part of C++.

And this is off-topic. The problem you are having has nothing to do wiith Code::Blocks.
Title: Re: #include file not found
Post by: Radek on November 17, 2011, 04:46:24 pm
fstream.h and fstream are (should be) the same header. Write fstream.h yourself:

Code
#pragma once
#ifdef  __CPLUSPLUS
#include <fstream>
#else
#error "only for C++"
#endif

Most of compilers do something like this but in opposite fashion  :) They have "traditional" headers (like fstream.h) for backward compatibility and redirect "new style" headers (like fstream) to them. You have only a "new style" header and redirect the "traditional" header to it. Everybody who will compile your program and who will have fstream.h should pass.