Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is wrong (time function und dos)

Status
Not open for further replies.

willi808

Programmer
Jun 11, 2003
14
DE
hello,

what is wrong?
i want to get the creation time of a directory (tcbuffer shows a wrong value).
'buffer' is an array with actual path...


struct _stat buf; //buffer of file status informations
struct tm *crTime; //time struct
char tcbuffer[500], tabuffer[500]; //array's for actual (ta...) und creation (tc...) time
time_t date; //time value

*tabuffer = NULL;
*tcbuffer = NULL;

_chdir(buffer);

//get actual date
_strdate(tabuffer);
//print actual date
printf("ta: %s\n", &tabuffer);

//get informations (buf) from actual directory (buffer)
_stat(buffer, &buf);

//copy date from directory info to time value
date = buf.st_ctime;

time(&date);
crTime = gmtime(&date);

//formats time struct to string
strftime( tcbuffer,9,"%m/%d/%y\n", crTime );
//pint creation time
printf("tc: %s\n",&tcbuffer );
 
Sorry, I do not understand exactly. Do you want to print all creation times of each file in a directory, is it?

Entschuldige, ich habe es nicht genau verstanden. Du willst Dir die Erstellungszeiten aller Dateien eines Verzeichnisses anzeigen lassen?

I see some problems ...
Ich sehe einige Probleme ...

>char tcbuffer[500], tabuffer[500];
You create 2 static buffers...
Du legst 2 statische Puffer an...

>*tabuffer = NULL;
>*tcbuffer = NULL;
... and try to set the first element to NULL (4bytes to 1char)
... und versuchst, dem ersten Element einen NULL-Zeiger zuzuweisen (4 Bytes auf ein char)

the rest I do not know
den Rest kenne ich nicht

I hope I could help a bit
Ich hoffe, ich konnte wenigstens etwas helfen

:-V


Greetings Andreas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top