为什么这样做:
char *fd = "myfile.txt";
struct stat buf;
stat(fd, &buf);
int size = buf.st_size;
printf("%d",size);
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
char *fd = "myfile.txt";
struct stat *buf;
stat(fd, buf);
int size = buf->st_size;
printf("%d",size);
Run Code Online (Sandbox Code Playgroud)