Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brunofonseca/2c14104820e68ce93fd5031c32facd56 to your computer and use it in GitHub Desktop.
Save brunofonseca/2c14104820e68ce93fd5031c32facd56 to your computer and use it in GitHub Desktop.
/*
After VS2010 compiles the generator, the DOS interface will flash back,
terms of settlement:
1. Add getchar () after the source program;
2. After adding header file, write system ("pause") before the end of main function;
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <Windows.h>
int main()
{
FILE *fp = NULL;
char *s="adasdsadasd";
time_t timep;
struct tm *p;
fp = fopen("C:/Users/Bruno Fonseca/Downloads/a.txt","a");
while(1)
{
time(&timep);
p=gmtime(&timep);
fputs ("Data :", fp);
fprintf (fp, "%d", p->tm_year + 1900); // get the year
fputs(":",fp);
fprintf (fp, "%d", p->tm_mon + 1); // get the month
fputs(":",fp);
fprintf (fp, "%d", p->tm_mday); // get date
fputs(" ",fp);
fputs ("time:", fp);
fprintf (fp, "%d", p->tm_hour + 8); // when getting
fputs(":",fp);
fprintf (fp, "%d", p->tm_min); // get the score
fputs(":",fp);
fprintf (fp, "%d", p->tm_sec); // get seconds
fputs(" Rotina executada com sucesso... ",fp);
fputs ("", fp);
fprintf (fp, "%d", p->tm_yday); // get the day of this year
fputs ("day \ n", fp); // line feed
fputs("\r\n",fp);
//sleep (1000); // 1s save once
system ("pause");
}
fclose(fp);
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment