Answer the question
In order to leave comments, you need to log in
Pointer to end of file C++
Hello.
Can't get end of file pointer.
Tried to do like this:
std::fstream f;
f.open("test.txt");
std::cout<<*f.ate;
Answer the question
In order to leave comments, you need to log in
It is not very clear how the pointer to the end of the file should look like. You want to read the last n bytes then you need to do
const int needed_bytes = 10;
f.seek(0, is.end);
int length = f.tellg();
f.seek(0, length - needed_bytes);
f.read ...
In general, a file is represented by a file descriptor, and when a file is opened, it is not completely transferred to RAM, so a const char* type pointer to some place in the file cannot be obtained without doing the operation described above. mmap exception, but that's beyond the scope of your question
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question