Jump to content
  • Advertisement
Sign in to follow this  
orcfan32

ofstream - Dev-cpp

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

I'm using Windows XP, Dev-Cpp and I was wondering with the function of code that I made: void OFile(std::string Name, std::string Text) { ofstream FileOut ( Name ); FileOut<<Text; cout<<Name; } It says that 'Name' is an invalid candidate. I have fstream and string included. If you put the name of the file in double quotes, it works fine, but then it's hard coded. Can you help me with this?

Share this post


Link to post
Share on other sites
Advertisement
ofstream takes a char*, not a std::string, so you need to pass it Name.c_str().

Share this post


Link to post
Share on other sites
Thanks for fast replies, guys! I got it working now. And I don't think Name is reserved. I use it many times in programs that need a name.

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!