c/c++文件相关
取的文件大小
1.?int fd = open("data.txt",O_RDONLY);
int len = lseek(fd,0,SEEK_END);
?
2.?struct?stat?sb; ?
if ((fstat(fd, &sb)) == -1) {?
perror("fstat");
}
sb.st_size
3.
?if ((mapped = (char *)mmap(NULL, sb.st_size, PROT_READ | ??
? ? ? ? ? ? ? ? ? ? PROT_WRITE, MAP_PRIVATE, fd, 0)) == (void *)-1) { ?
? ? ? ? perror("mmap"); ?
?
? ? } ?
轉(zhuǎn)載于:https://www.cnblogs.com/anjsxz/p/3732888.html
總結(jié)
- 上一篇: 转:jQ函数after、append、a
- 下一篇: 我的360破解考题答案