相关疑难解决方法(0)

如何在Linux上用C++读取带有read()和O_DIRECT的文件?

我正在寻找解决上述问题的解决方案.

这是我的"不工作代码".charsInCurrentBuffer总是返回-1!

#define BUFSIZE 512

char *bufferA = new char[BUFSIZE];
char *bufferB = new char[BUFSIZE];

const char *inputFile = "in.txt";

if ( (fdInputFile = open(inputFile, O_DIRECT) ) != -1) {
    cout << "input opened!" << endl;
} else {
    cout << "can't open input file!";
}

int charsInCurrentBuffer = read(fdInputFile, currBuffer, BUFSIZE);
cout << charsInCurrentBuffer << endl;
Run Code Online (Sandbox Code Playgroud)

c++ linux file

2
推荐指数
1
解决办法
5537
查看次数

标签 统计

c++ ×1

file ×1

linux ×1