代碼 如下, 在VBox上,還是會報溢位錯誤 ,請問應該如何解決。
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
int main(int argc,char* argv[])
{
int fd = open("test.txt",O_WRONLY |O_TRUNC |O_CREAT,0777);
if(fd ==-1)
{
perror("open");
exit(1);
}
int n = lseek(fd,4*1024*1024*1024,SEEK_CUR);
write(fd,"jack",5);
close(fd);
exit(0);
}
uj5u.com熱心網友回復:
Vbox是實模式吧,不能訪問那么多記憶體。uj5u.com熱心網友回復:
4*1024*1024*1024
這是4G的空間,建議減少到4*1024試試,應該就不會有溢位的提示了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20700.html
標籤:C語言
