#include <stdio.h>
#include <time.h>
#include <cstring>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main ()
{
ofstream file;
stringstream ss;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
char g[30];
char buffer[10];
itoa(timeinfo->tm_mday,buffer,10);
strcat(g,buffer);
strcat(g,"-");
itoa(timeinfo->tm_mon+1,buffer,10);
strcat(g,buffer);
strcat(g,"-");
itoa(timeinfo->tm_year+1900,buffer,10);
strcat(g,buffer);
file.open((const char*)g, ios_base::app);
if (!file) cout<<"error"<<endl;
file<<"success!"<<endl;
file.close();
system("PAUSE");
return EXIT_SUCCESS;
}
The file does not want to be opened - Can anyone help me?