I am a C++ newbie and this is my first post to the forum. I will begin with saying that this site is awesome and I have been using the examples to gain better understanding of the language.
I am running some simulations in C++ and I need to store data to the disc intermittently. e.g., for Run 1, I need to save data in File_1.txt
I am able to generate a string "File_1.txt" (by converting integer 1 to string 1), however the following piece of code is giving error
You can use the following: myfile.open(filename.c_str());
c_str(), a member function of the string type, converts a string to a C-style string (character array), which is what the open() function is looking for.