Jump to content
  • Advertisement

Archived

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

NewbJ

fstreams and variable files

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!