Jump to content
  • Advertisement
Sign in to follow this  
KuroKitten

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

This topic is 4688 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
Advertisement
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
Hmm, 'twas using namespace std; Which is odd cuz i havn't had problems with not using it untill now, i've always jsut used <cstdlib> *shrugs* aww well works now, lol.

Meow.

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
im curious to see how your theory on strings pertains to chars of the unsigned variety =_=

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!