- 论坛徽章:
- 0
|
zhoudh@zhoudh-linux:~/Templates$ cat test.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
int main()
{
struct stat info;
memset(&info, 0, sizeof(struct stat));
stat("./test.c", &info);
printf("size: %d\n", info.st_size);
return 0;
}
zhoudh@zhoudh-linux:~/Templates$ stat test.c
File: `test.c'
Size: 273 Blocks: 8 IO Block: 4096 regular file
Device: 303h/771d Inode: 1230175 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ zhoudh) Gid: ( 1000/ zhoudh)
Access: 2007-03-15 09:39:59.000000000 +0800
Modify: 2007-03-15 09:39:36.000000000 +0800
Change: 2007-03-15 09:39:37.000000000 +0800
zhoudh@zhoudh-linux:~/Templates$ ./test
size: 273
zhoudh@zhoudh-linux:~/Templates$ vi test.c
zhoudh@zhoudh-linux:~/Templates$ cat test.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
int main()
{
struct stat info;
// memset(&info, 0, sizeof(struct stat));
stat("./test.c", &info);
printf("size: %d\n", info.st_size);
return 0;
}
zhoudh@zhoudh-linux:~/Templates$ gcc test.c -o test
zhoudh@zhoudh-linux:~/Templates$ stat test.c
File: `test.c'
Size: 275 Blocks: 8 IO Block: 4096 regular file
Device: 303h/771d Inode: 1230176 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ zhoudh) Gid: ( 1000/ zhoudh)
Access: 2007-03-15 09:42:33.000000000 +0800
Modify: 2007-03-15 09:40:30.000000000 +0800
Change: 2007-03-15 09:40:30.000000000 +0800
zhoudh@zhoudh-linux:~/Templates$ ./test
size: 275
zhoudh@zhoudh-linux:~/Templates$ |
|