I want to output time to a text file, and the time should be formatted as (dd-mm-yy). I've referred to How to print time in format: 2009‐08‐10 18:17:54.811 (using code from top answer) and I am now stuck with this piece of code:
int main()
{
time_t timer;
char buffer[26], line[50]; // Hoping to feed in date and time into a string (line[50])
struct tm* tm_info;
time(&timer);
tm_info = localtime(&timer);
strftime(buffer, 26, "%d-%m-%y %H:%M:%S", tm_info);
puts(buffer);
return 0;
}
Which give mes an output of the current local time and date in the format (dd-mm-yy) and (hh-mm-ss) on stdout. So now I'm just wondering if I can feed this format into a text file as well.
Thanks for any help.