I'm trying to write an application where I ask the user for the text that goes inside their file and then what the file should be called. here so far is the code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int number;
wchar_t* fileName [80];
printf("What should this file say?\n");
scanf("%d", &number);
printf("What should the file's name be?\n");
scanf("%s", fileName);
ofstream myfile;
myfile.open (fileName);
myfile << number;
myfile.close();
return 0;
}
my problem is when they try to save the file with the name they made, the
"myfile.open()" wants a constant and not a variable. how do I alter the code to make 'fileName' work the file's name?