Sign in to follow this  
kinglink

File I/O question (missing IOS)

Recommended Posts

kinglink    100
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 <fstream> //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 this post


Link to post
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.

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

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

Share this post


Link to post
Share on other sites
kinglink    100
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 this post


Link to post
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 use
inputfile.open("poop.cpp",ios::binary|ios::in);
// instead of
inputfile.open("poop.cpp",std::ios::binary|std::ios::in);


Share this post


Link to post
Share on other sites
kinglink    100
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this