News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

#include file not found

Started by PetruD, November 17, 2011, 12:06:51 AM

Previous topic - Next topic

PetruD

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.

oBFusCATed

Yes, a modern book to teach you modern c++ :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

zabzonk

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:

#include <fstream>

PetruD

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.

zabzonk

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.

Radek

fstream.h and fstream are (should be) the same header. Write fstream.h yourself:


#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.