I recently created a program that replaces the contents of a file with different contents. One of my requirements was that the file was same size when I was done. Coding in C the file size is handled by the system. On google I found links to truncate a file but nothing telling me how to get the size.
I tried size = sizeof (filepointer); where filepoint is of type FILE* and the file has been opened but that returns 8. I tried sizeof (pathtofile) but that returns the size of the path. What I ended up doing was the following:
int FileSize(FILE *index)
int size = 0;
I was wondering if there is a more eloquent way to achieve the same result. Any suggestions would be greatly appreciated. It should return size - 1 (I handle that later in the program).
program built using vc++ from visual studio 6