C, Zeit, Tag, Monat, Jahr und mehr

Habe ich ein problem.
Ich brauche, um Dinge wie Tag des Jahres, Tag des Monats, Monat, Jahr usw.
Ich benutze diesen code:

#include <stdio.h>
#include <time.h>
int main(void)
{    
    time_t liczba_sekund;
    struct tm strukt;
    time(&liczba_sekund);
    localtime_r(&liczba_sekund, &strukt); 
    printf("today is %d day of year\nmonth is %d, month's day %d\n", strukt.tm_yday+1, strukt.tm_mon+1, strukt.tm_mday); 
    return 0;
}

Erste Sache: warum wird gcc -std=c99 -pedantic -Wall zurückkehren diese Warnung:

Meine Eingabe: gcc-test_data.c -o-test_data.aus -std=c99 -pedantic -Wall -

Ausgabe:

test_data.c: In function 'main':

test_data.c:11:3: Warnung: implizite Deklaration der Funktion "localtime_r' [-Wimplicit-function-declaration]

Zweite Sache: wie es funktioniert auf windows? Beim Versuch zu kompilieren mit Dev-C habe, bekam ich diese:
http://imgur.com/U7dyE

@@EDIT --------------------
Ich habe gefunden ein Beispiel für Ihre localtime Vorschlag:

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

int main ()
{
    time_t time_raw_format;
    struct tm * ptr_time;

    time ( &time_raw_format );
    ptr_time = localtime ( &time_raw_format );
    printf ("Current local time and date: %s", asctime(ptr_time));
    return 0;
}

Wie kann ich dies ändern Datum-format wie diesem: 5.12.2012 oder 5-12-2012? Und wie man den Tag des Jahres?

Ich würde lieben, wenn die Lösung funktioniert sowohl auf windows und linux.

InformationsquelleAutor Dominik C | 2012-12-05

Schreibe einen Kommentar