Sign in to follow this  

Dev-C++ doesn't like fstream or string O.o

This topic is 4379 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

For some reason, Dev C++ isn't regonizing fstream or string at all. It figures i'm trying to declare variables called fstream and string, and not the other way around. I've been using Dev C++ for the fact that it can hdie the console window and run things in the background (having a black box up all the time jsut for a background changer is rather bothersome). Does anyone know why Dev C++ doesn't like strings and fstreams? Thanks in advance^^ Mreow.

Share this post


Link to post
Share on other sites
simple do this.


#include <fstream>
#include <string>

//you do this because I am not sure what features you want to use
using namespace std;

int main()
{

//do whatever you want here using fstream or string such as
string stThisIsAString;

ofstream fout;
//ect...

return 0;
}

Share this post


Link to post
Share on other sites
As was pointed out by Gor435, you were probabally missing some form of:

using namespace std;
...
using std::string;
using std::ifstream;
using std::ofstream;
...
std::string str1;
std::ifstream IF;
std::ofstream OF;

That is unless you didn't do what stylin said [wink]

Share this post


Link to post
Share on other sites
Those items aren't present in <cstdlib>, and cstdlib "stuff" is not in the standard namespace, because it's imported from C and mostly intended for backwards compatibility (although it isn't actually deprecated like iostream.h etc.). You should be using the new stream libraries because they don't spit on C++'s enhanced type system, and you should be using std::string because... well, you *have* read my other posts yes? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
im curious to see how your theory on strings pertains to chars of the unsigned variety =_=


The theory goes that beginners normally don't (or shouldn't have to try to) solve the kinds of problems where those sorts of things are appropriate. :)

Share this post


Link to post
Share on other sites

This topic is 4379 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.

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