barton4
04-03-2007, 18:35
Ich wollt ein programm schreiben das mir ertas bei der zeitberchnung hilft.
Leider funktioniert schon der Anfang nicht.
Die Funktion localtime() die mir aus der unix zeit eine structur tm erzeugt gibt immer NULL zurück
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t now, final;
struct tm bdnow, bdfinal;
struct tm *bdresult;
time(&now);
printf("seconds since 1970: %i\n", now);
if( (bdresult = localtime(&now)) == NULL );
{
perror("err::::");
}
memcpy(bdresult, &bdnow, sizeof(struct tm));
printf("%i\n", bdnow.tm_mon);
}
weis jemand was ich da falsch gemacht hab?
Leider funktioniert schon der Anfang nicht.
Die Funktion localtime() die mir aus der unix zeit eine structur tm erzeugt gibt immer NULL zurück
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t now, final;
struct tm bdnow, bdfinal;
struct tm *bdresult;
time(&now);
printf("seconds since 1970: %i\n", now);
if( (bdresult = localtime(&now)) == NULL );
{
perror("err::::");
}
memcpy(bdresult, &bdnow, sizeof(struct tm));
printf("%i\n", bdnow.tm_mon);
}
weis jemand was ich da falsch gemacht hab?