I've been playing around with files and streams and just hit a pot hole.
My goal is to be able to input time and date into a file when say someone "clocks in/out". Just a little program that will help me keep up with my time in school.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream a_file ( "example.txt", ios::app);
if ( !a_file.is_open() ) {
// The file could not be opened
}
else {
// Safely use the file stream
}
a_file << system("date /t") << "\n" << system("time /t") << "\n";
a_file. close();
}
The problem is that when I open "example.txt" all I get is a zero (0).
I think my problem has to do with I'm inputing an integer instead of a string, since I'm working with a text file. If anyone has some input, I'd enjoy hearing from you.