jay-t
07-08-2010, 18:50
Hallo, ich versuche gerade mit stat() die Zeit und das Datum der letzten Dateimodifikation auszulesen:
In diese Struktur:
struct time
{
U1 hour;
U1 min;
U1 sec;
};
struct date
{
U4 year;
U1 month;
U1 day;
};
struct memory
{
U1 type;
U4 hash;
void *data;
U8 linknum;
U8 *links;
U1 strenght;
struct time time;
struct date date;
struct date expires;
};
Hier ist die Funktion:
U1 set_time_from_file (U8 index, U1 *file)
{
struct stat buf;
if (! stat (file, buf))
{
return (FALSE);
}
tm = localtime (buf->st_mtime);
memory[index].time.hour = tm->tm_hour;
memory[index].time.min = tm->tm_min;
memory[index].time.sec = tm->tm_sec;
memory[index].date.year = tm->tm_year + 1900;
memory[index].date.month = tm->tm_mon +1 ;
memory[index].date.day = tm->tm_mday;
#if DEBUG
printf ("set_time_from_file:\n");
printf ("time: %i:%i:%i\n", memory[index].time.hour, memory[index].time.min, memory[index].time.sec);
printf ("date: %i.%i.%i\n", memory[index].date.day, memory[index].date.month, memory[index].date.year);
#endif
return (TRUE);
}
Das gibt haufenweise Fehlermeldungen:
time.c:62: warning: assignment makes pointer from integer without a cast
time.c:64: error: subscripted value is neither array nor pointer
time.c:64: error: dereferencing pointer to incomplete type
time.c:65: error: subscripted value is neither array nor pointer
time.c:65: error: dereferencing pointer to incomplete type
time.c:66: error: subscripted value is neither array nor pointer
time.c:66: error: dereferencing pointer to incomplete type
Wie geht das richtig? Was ist falsch?
In diese Struktur:
struct time
{
U1 hour;
U1 min;
U1 sec;
};
struct date
{
U4 year;
U1 month;
U1 day;
};
struct memory
{
U1 type;
U4 hash;
void *data;
U8 linknum;
U8 *links;
U1 strenght;
struct time time;
struct date date;
struct date expires;
};
Hier ist die Funktion:
U1 set_time_from_file (U8 index, U1 *file)
{
struct stat buf;
if (! stat (file, buf))
{
return (FALSE);
}
tm = localtime (buf->st_mtime);
memory[index].time.hour = tm->tm_hour;
memory[index].time.min = tm->tm_min;
memory[index].time.sec = tm->tm_sec;
memory[index].date.year = tm->tm_year + 1900;
memory[index].date.month = tm->tm_mon +1 ;
memory[index].date.day = tm->tm_mday;
#if DEBUG
printf ("set_time_from_file:\n");
printf ("time: %i:%i:%i\n", memory[index].time.hour, memory[index].time.min, memory[index].time.sec);
printf ("date: %i.%i.%i\n", memory[index].date.day, memory[index].date.month, memory[index].date.year);
#endif
return (TRUE);
}
Das gibt haufenweise Fehlermeldungen:
time.c:62: warning: assignment makes pointer from integer without a cast
time.c:64: error: subscripted value is neither array nor pointer
time.c:64: error: dereferencing pointer to incomplete type
time.c:65: error: subscripted value is neither array nor pointer
time.c:65: error: dereferencing pointer to incomplete type
time.c:66: error: subscripted value is neither array nor pointer
time.c:66: error: dereferencing pointer to incomplete type
Wie geht das richtig? Was ist falsch?