Code::Blocks Forums

User forums => Help => Topic started by: deepak643 on March 08, 2014, 01:23:35 am

Title: fstream: No such file or directory
Post by: deepak643 on March 08, 2014, 01:23:35 am
When I include fstream, my program throws

fatal error: fstream: No such file or directory.

How to resolve this? It seems to be wierd.. I am using gcc compiler.

Please suggest
Title: Re: fstream: No such file or directory
Post by: oBFusCATed on March 08, 2014, 01:46:48 am
gcc or g++? .c or .cpp? Have you read the FAQ on the wiki.codeblocks.org?
Title: Re: fstream: No such file or directory
Post by: deepak643 on March 08, 2014, 04:21:17 am
I am using GCC (not g++).
Its a C program (.c).

I checked the FAQ in this forum.. the below is the thread I have found.. but i didn't find it useful.

http://forums.codeblocks.org/index.php?topic=12666.msg%25msg_id%25

Title: Re: fstream: No such file or directory
Post by: oBFusCATed on March 08, 2014, 08:58:10 am
Its a C program (.c).
Then why are you trying to use a c++ header? This is never going to work.
Title: Re: fstream: No such file or directory
Post by: SuperBoi45 on April 05, 2014, 11:48:54 pm
<fstream> is a C++ file. Are you trying to use the standard C++ file stram std::fstream? If so, then make a C++ project. For C projects you have to use <cstdio> and FILE*.
Title: Re: fstream: No such file or directory
Post by: stahta01 on April 06, 2014, 02:45:02 am
<fstream> is a C++ file. Are you trying to use the standard C++ file stram std::fstream? If so, then make a C++ project. For C projects you have to use <cstdio> and FILE*.

Correction <cstdio> is ALSO a C++ header, stdio.h is a C header.

Tim S.
Title: Re: fstream: No such file or directory
Post by: scarphin on April 06, 2014, 04:49:07 am
For C projects you have to use <cstdio> and FILE*.
I think he meant C projects to be compiled with a C++ compiler.
Title: Re: fstream: No such file or directory
Post by: Jenna on April 06, 2014, 09:53:23 am
For C projects you have to use <cstdio> and FILE*.
I think he meant C projects to be compiled with a C++ compiler.
I am using GCC (not g++).
Its a C program (.c).
That means he has to use the "real" c-headers.