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;
}
}
网友评论