in
how can i make the name of the archive be a variableCode:ofstream a_file("data.1")
Printable View
in
how can i make the name of the archive be a variableCode:ofstream a_file("data.1")
Take off the quotes.
I don't know how data.1 is a variable name, as '1' is not an acceptable variable declaration, nor is anything with a '.' in it.
A variable is something that holds data.
Put what you want into the variable.
Code:#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream out;
char file_name[16];
cout << "Enter the name of the file (including ext, IE test.txt: ";
cin >> file_name;
out.open(file_name);
out << "See, like this.";
out.close();
return 0;
}