By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,483 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

Display time for every file operation in c++

P: 1
Hi,
I did a project in c++ to do file operations.The output of the program would be like this
File create\File1_1 created
File create\File1_1 Copied to copy\FileDest_1
File copy\FileDest_1 (6302 Bytes) Renamed to copy\File2_1 (6302 Bytes)
Files create\File1_1 and copy\File2_1 are equal
.............................

I would like to append time to the output. I tried to use the time function, it displays only the current time. I want to display the time for every single file operation. any sample code would be very helpful.

Thanks
Vchezel
Nov 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: 32
emp
include time.h and sys/timeb.h

char tsBuf[20];


time_t ltime;
struct tm *today;
time(&ltime);
today = localtime(&ltime);

strftime(tsBuf,18,"%D %T, today);


tsBut comes back populated with currentsystem date and time in the format
governed by the %D %T delimiters. you can concatenate the tsBuf to your output line.

For an explanation of more functionality of the delimeters go to

http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
Nov 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.