Thread: How can I know the actual bytes read in a file read

  1. #1
    Registered User
    Join Date
    Apr 2005

    How can I know the actual bytes read in a file read

    I have a file open for binary read as follow
    ifstream fin(inFileName, ios::in | ios::binary);, sizeof read_buffer);
    Is there any way for me to know how many bytes were actually read? Suppose I am on my final read of the file and the number of bytes left is smaller than the size of my read_buffer, I want to know how many bytes of new data I read into the buffer. I thought would return an int of number of bytes read but it doesn't. Thanks in advance.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    istream::read() returns the stream. You probably want istream::readsome().
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Reverse Engineering on a Download file
    By c_geek in forum C Programming
    Replies: 1
    Last Post: 03-22-2008, 03:15 PM
  3. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  5. archive format
    By Nor in forum A Brief History of
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM