• Advertisement
Sign in to follow this  

File I/O question (missing IOS)

This topic is 4722 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 <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
Advertisement
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
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
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
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
std::ios::in is redundant - you are using an std::ifstream. They only do input.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement