i have an error on this code i cant open example.txt using my declarations.

#include <fstream>
#include <iostream>
#include <string.h>
#include <time.h>
#include <string.h>
using namespace std;
int main()
{
char time[9];
char date[9];
_strtime(time);
_strdate(date);
string nop;
nop = "example.txt";

ofstream dtfile(""nop"", ios::app);
dtfile<<time;
dtfile<<" "<<date<<endl;
dtfile.close();
}

>>ofstream dtfile(""nop"", ios::app);

ofstream dtfile(nop.c_str(), ios::app);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.