Learning C, and I'm trying to get a visual comparison of the types and sizes of variables returned stat()for atime / mtime attributes and for nsec precision values.
I run stat()in a file and want to get the mtime and mtime nsec values โโfrom the returned stat structure, and then save these values โโin separate variables (which I then want to pass into utimes()... a long story!).
According to http://www.kernel.org/doc/man-pages/online/pages/man2/stat.2.html#NOTES I can get a value from st_mtim.tv_nsecor st_mtimensecdepending on various OS / build conditions. In my real program, I will check both options and use what is installed, or just lean back on the usual second accuracyst_mtime
What type and size of variable must be declared in order to keep the normal timestamp returned st_mtime?
What type and size of variable must be specified to declare an nsec value from st_mtim.tv_nsecor st_mtimensec?
Are they decimal, including the number of whole seconds of time? Or do they just return the nsec part of the time?
Do I need to declare different sizes of variables for nsecs depending on my system architecture?
And finally, what conversion qualifiers do I need to output these variables with printf()?
Cheers, B
source
share