Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NewbJ

fstreams and variable files

This topic is 5316 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''ve been working on a little program, and need to open a file, but one that the user defines (and, therefore, one that is defined at at runtime). I''ve tried using strings and character arrays for the file path, but neither want to pass to the fstream open() function. Does anyone know how to do this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
char szFile[256];
cout << "Enter a filename: ";
cin.getline(szFile, 255);

ofstream ofFile;
ofFile.open(szFile, ... );

I don''t see why that wouldn''t work.

Share this post


Link to post
Share on other sites
sry, I was just being stupid...the fstream function wasn''t my problem. yeah, it works that way. I''ll be more careful to isolate the problem when I post next time

Share this post


Link to post
Share on other sites

  • 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!