niedziela, 5 lutego 2017

Saving now time on the Web page (gcc)

#include <stdio.h>
#include <sys/time.h>
#include <time.h>



int main(int argc, char **argv)
{
    FILE *my_file;
    char my_time;
    struct timeval time1;
    struct tm *time2;
    gettimeofday(&time1,NULL);
    time2=localtime(&time1.tv_sec);
    char my_buffor[64];
    char *my_page=
    "<html>\n"
    "</head>\n"
    "<body>\n"
    " <p> Now time: %s.</p>\n"
    " </body>\n"
    "</html>\n";
    strftime(my_buffor,sizeof(my_buffor),"%H:%M:%S",time2);
    my_file=fopen("my_site.html","w");
    fprintf(my_file,my_page,my_buffor);
    fflush(my_file);
    fclose(my_file);
   
   
   
    return 0;
}

Brak komentarzy:

Prześlij komentarz