打印文件/导演信息(inode)

我想打印目录的一些信息。 我的代码是:

#include  #include  #include  #include  #include  #include  #include  #include  #include  int main (int argc, char *argv[]) { struct stat fileStat; int fd=0; if ( ( fd = open (argv[1] , O_RDONLY) ) == -1){ perror ( "open " ); exit (1) ; } if(fstat(fd, &fileStat)printf("File Size: \t\t%d bytes\n",fileStat.st_size); printf("Number of Links: \t%d\n",fileStat.st_nlink); --->printf("File inode: \t\t%d\n",fileStat.st_ino); return 0; } 

我收到一些警告:

 inode_test.c:24:5: warning: format '%d' expects argument of type 'int', but argument 2 has type '__off_t' [-Wformat] inode_test.c:26:5: warning: format '%d' expects argument of type 'int', but argument 2 has type '__ino_t' [-Wformat] 

箭头显示每个警告的行。 你能帮我吗? 提前致谢!

我找到了答案。 这些格式是long unsigned int。 所以这是%lu。 无论如何感谢@haccks的帮助!

要打印__off_t您需要%jd说明符。