ofstream from string

Help (please)-

I need 2 output files
1- Named "out.txt" to write output data (done)
2- Named based on a string file name read from a fie. For example, in a file there is a string called "test01.txt" which is the name that I need for my second output file.

I have tried the following:
getline(in, saveName);
ofstream file;
file.open(saveName.c_str());

but the file name saved in the string saveName is never generated. If I fat-finger in "test01.txt" as opposed to the saveName.c_str() it works but I need this file name to be generated dynamically.

What am I missing?
The code you have there should do what you want. Something else must be wrong.
cout saveName to the console to see if it's being read correctly.

If not: is the input file open? is it at the correct position in the file (possibly the beginning)? is there any whitespace (spaces, tabs, newlines) that should be skipped first?
Topic archived. No new replies allowed.