How to get file size in C++?

This is a discussion on How to get file size in C++? within the C++ Programming forums, part of the General Programming Boards category; IŽd like to read in some bytes from a file, but first I need to know the file size. How ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    29

    How to get file size in C++?

    IŽd like to read in some bytes from a file, but first I need to know the file size. How does one do that in C++?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is seekg(0, std::end) and tellg().

    Kuphryn

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Minor correction
    Code:
    seekg(0, ios::end);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 08:54 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  3. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21