# File I/O question (missing IOS)

## Recommended Posts

Standard configuration, Large program Has this file now added (was a bigger thing but I removed needless things for ease of use and Still gives error.
Quote:
 #include //template Class booltemp() { std::ifstream inputfile; inputfile.open("poop.cpp"),ios::binary|ios::in); if(!inputfile.is_open()) //Make sure File is open already from Player. return -2; int tempinput; while(!inputfile.eof()) //While not at end of file. { inputfile.read((char *)(&tempinput), sizeof(tempinput)); } return true; }
c:\project\Nog\Queue.cpp(7): error C2653: 'ios' : is not a class or namespace name c:\project\Nog\Queue.cpp(7): error C2065: 'binary' : undeclared identifier c:\project\Nog\Queue.cpp(7): error C2653: 'ios' : is not a class or namespace name c:\project\Nog\Queue.cpp(7): error C2065: 'in' : undeclared identifier (file name is queue.cpp, but it's not currently being used) Most files on the web seem to only include <fstream> even when using ios names to open files. I am using VS 2003 .net, (first time doing I/O in here. so it might be something with this compiler) Anyone willing to give me an idea what I'm doing wrong (yet again)?

##### Share on other sites
Doggan    528
std::ios::binary, std::ios::in

##### Share on other sites
nmi    978
inputfile.open("poop.cpp"),ios::binary|ios::in);

should be

inputfile.open("poop.cpp",ios::binary|ios::in);

in any case, since parantheses must match.

http://www.cplusplus.com/ref/iostream/

and here:
http://www.cppreference.com/

##### Share on other sites
Thanks for that,nmi, though I pray I would have realized that, the official code doesn't have a hard coded text name nor the extra ), I just was trying to recreate the problem.

And thanks for the solution Doggan I don't think I'll ever get use to these "invisible" namespaces.

##### Share on other sites
Endar    668
If you're having a lot of problems with namespacs, the best way to get them out of the way for the moment, is at the top after including all the files, put "using namespace std;". This is of course for the namespace "std" which is practically everything in the C++ standard library. So, fstream, iostream, practically everything.

#include <fstream>#include <iostream>using namespace std;// blah// now useinputfile.open("poop.cpp",ios::binary|ios::in);// instead ofinputfile.open("poop.cpp",std::ios::binary|std::ios::in);

##### Share on other sites
I mostly meant which namespace is used for all these fun little tools. (of course apparently they all use std so it's moot :) ) Most MSDN docs tend to forget the namespace field.

##### Share on other sites
Fruny    1658
std::ios::in is redundant - you are using an std::ifstream. They only do input.