C 文件/控制器(inode)的打印信息

C 文件/控制器(inode)的打印信息,c,inode,fstat,C,Inode,Fstat,我想打印一些目录信息。我的代码是: #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <time.h> #include <string.h&g

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

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <time.h>
#include <string.h>

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)<0) return 1;

    printf("Information for %s\n",argv[1]);
    printf("---------------------------\n");
    --->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;
}

箭头显示每个警告的线条。你能帮忙吗?提前谢谢

要打印
\u off\t
您需要
%jd
说明符。

我找到了答案。这些格式是长的无符号整数。所以它是%lu。无论如何,谢谢@haccks的帮助

还有警告。使用%td或%jd。作为备注,您可以在“lu”前面添加t/j加法说明符(但在%)
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]