Reputation: 1546
I am trying to use fileIO in my windows VC++2008 (this is what I have set up for everything I need to do) program, and I have done the following
#include <iostream>
#include <fstream>
#include <string>
....
ostream Output;
intelisense is working fine, and even gives me the methods for the object, but my compiler throws that it does not recognize ostream even though I know that it resides in the fstream header file that is included.
is there something wrong with my compiler, and how do I check?
additional info
I have done the following, and it now recognizes the stream, but I now get a different error
std::ofstream Output // instead of ostream Output
Output.open("Output/log.txt", ios::out); //so that I can open the file and specify output as ofstream can go both ways.
when I tried to do this as one line with just a constructor I got this issue"
1>c:...\engine\gsp420maincore\gsp420maincore\messagequeue.cpp(141) : error C2664: 'std::basic_ostream<_Elem,_Traits>::basic_ostream(std::basic_streambuf<_Elem,_Traits> *,bool)' : cannot convert parameter 1 from 'const char [15]' to 'std::basic_streambuf<_Elem,_Traits> *'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
when I use the current method my compiler states that
error C2653: 'ios' : is not a class or namespace name
Upvotes: 0
Views: 763
Reputation:
You could use ofstream
if you're trying to output to a file:
#include <fstream>
std::ofstream o("file.txt");
o << "Hello File!";
o.close();
The std::
is needed if you're not using
the std namespace.
Upvotes: 2
Reputation: 13097
Have you tried std::ostream? You might not have included the namespace?
Upvotes: 1