0
long FileSize(FILE* f)
{
    if(f)
    {
        long size;
        long initpos = ftell(f);
        fseek(f,0,SEEK_END);
        size = ftell(f); //Get End Position Which
        fseek(f,initpos,SEEK_SET); //Go Back To Initial Position
        return size;
    }

    return 0;
}

Only 183 characters in text file but reports 197. Reason for this?

1
Contributor
1
Reply
3
Views
5 Years
Discussion Span
Last Post by ChaseRLewis
0

I was stupid. Reading a Text file doesn't give you the 0 string ender. Also the method that counted the characters doesn't count '\r' and '\n' characters.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.