美文网首页
从某一特定位置读取文件内容

从某一特定位置读取文件内容

作者: ChennelCiel | 来源:发表于2020-11-13 16:01 被阅读0次
FILE *file;
const char *fileName;
fileName= "xxx.txt";
int error = fopen_s(&file, fileName, "r");
if (error != 0)
    puts("Fail!打开文件失败!");

// point to end, get file size(char)
fseek(file, 0L, SEEK_END);
int size = ftell(file);

//  specified location    
unsigned int position = xxx;
unsigned int readSize = xxx;
for (int i = position; i < position+readSize ; i++) {
    if (k < size) {
        fseek(file, i, SEEK_SET);
        char ch = getc(file);
        cout << ch;
    }   
}

相关文章

网友评论

      本文标题:从某一特定位置读取文件内容

      本文链接:https://www.haomeiwen.com/subject/llypbktx.html