Hi there, I have a question about a really simple program. The code below doesn't work, the compiler comes back with "fatal error C1083: Cannot open include file: 'ofstream': No such file or directory":

#include <iostream>

#include <ofstream>

using namespace std ;

int main( )


ofstream myfile("newfile.txt") ;

myfile << "This file contains this sentence.\n" ;

myfile.close() ; 


if I instead replace

#include <ofstream>


#include <fstream>

it's all good.
I thought that if I want to create a file and input some data in it ofstream was enough, or if I wanted to read from a file I had to use ifstream. fstream, I thought, needs to be used only if I want to read and write...
Any suggestion? thanks

Well I always use fstream in my includes for file I/O.

>> 'ofstream': No such file or directory":

The C++ header files are listed in this Reference.

Brilliant mitrmkar,
thanks for that, I see, I was trying to use a header file that in fact doesn't exist!

thanks again