我想通過這樣來讀取文件中的最後50個字符:與FSEEK讀取文件的最後50個字符()
FILE* fptIn;
char sLine[51];
if ((fptIn = fopen("input.txt", "rb")) == NULL) {
printf("Coudln't access input.txt.\n");
exit(0);
}
if (fseek(fptIn, 50, SEEK_END) != 0) {
perror("Failed");
fclose(fptIn);
exit(0);
}
fgets(sLine, 50, fptIn);
printf("%s", sLine);
這並不返回任何遠程有道理。爲什麼?
+1爲UTF-8預警 –