#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char*argv[])
{
struct stat file;
int n;
if (argc != 2)
{
printf("Usage: ./a.out <filename>\n");
exit(-1);
}
if ((n = stat(argv[1], &file)) == -1)
{
perror(argv[1]);
exit(-1);
}
printf("Block size : %d\n", file.st_blksize);
}
Last line gives an error
format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__blksize_t’ [-Wformat=]
How to print out "st_blksize" of data??
Actually, st_blksize
is a unsigned long
typedefed datatype, hence use
printf("Block size : %ld\n", file_st.blksize);