Skip to content

Instantly share code, notes, and snippets.

@najashark
Last active April 25, 2018 15:37
Show Gist options
  • Save najashark/9da0b339fd096b0c7f429f6de35a7613 to your computer and use it in GitHub Desktop.
Save najashark/9da0b339fd096b0c7f429f6de35a7613 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include "fstream"
//#include "ctime"
#include "Windows.h"
using namespace std;
int main(int argc, char *argv[]) {
std::ofstream outfile(argv[1]);
//printf( argv[1]);
//time_t rawtime;
//struct tm * timeinfo;
//char buffer[80];
//time(&rawtime);
//timeinfo = localtime(&rawtime);
DWORD ticks = GetTickCount();
DWORD milliseconds = ticks % 1000;
ticks /= 1000;
DWORD seconds = ticks % 60;
ticks /= 60;
DWORD minutes = ticks % 60;
ticks /= 60;
DWORD hours = ticks; // may exceed 24 hours.
sprintf(buffer, "%d:%02d:%02d.%03d\n", hours, minutes, seconds, milliseconds);
//strftime(buffer, sizeof(buffer), "%d-%m-%Y %I:%M:%S", timeinfo);
//outfile << buffer << std::endl;
outfile << buffer << std::endl;
outfile.close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment