小编nec*_*net的帖子

在C上正确使用Stat

为什么这样做:

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)

c posix file

16
推荐指数
2
解决办法
6万
查看次数

标签 统计

c ×1

file ×1

posix ×1