Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 78a0b4d

Browse files
Ex 15-3: simple solution
1 parent 74888ed commit 78a0b4d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎15_File_Attributes/t_stat.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1818
The '-l' option indicates that lstat() rather than stat() should be used.
1919
*/
20+
#define _XOPEN_SOURCE 700
2021
#include <sys/sysmacros.h>
2122
#if defined(_AIX)
2223
#define _BSD
@@ -79,9 +80,13 @@ displayStatInfo(const struct stat *sb)
7980
printf("Optimal I/O block size: %ld bytes\n", (long) sb->st_blksize);
8081
printf("512B blocks allocated: %lld\n", (long long) sb->st_blocks);
8182

82-
printf("Last file access: %s", ctime(&sb->st_atime));
83-
printf("Last file modification: %s", ctime(&sb->st_mtime));
84-
printf("Last status change: %s", ctime(&sb->st_ctime));
83+
char atime_str[26], ctime_str[26], mtime_str[26];
84+
ctime_r(&sb->st_atime, atime_str); atime_str[19] = '0円';
85+
ctime_r(&sb->st_mtime, mtime_str); mtime_str[19] = '0円';
86+
ctime_r(&sb->st_ctime, ctime_str); ctime_str[19] = '0円';
87+
printf("Last file access: %s.%09ld %s", atime_str, sb->st_atim.tv_nsec, atime_str+20);
88+
printf("Last file modification: %s.%09ld %s", mtime_str, sb->st_mtim.tv_nsec, mtime_str+20);
89+
printf("Last status change: %s.%09ld %s", ctime_str, sb->st_ctim.tv_nsec, ctime_str+20);
8590
}
8691

8792
int

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /