Thread: Does the size on disk always have to be an even number?

  1. #1
    Registered User
    Join Date
    Nov 2011

    Does the size on disk always have to be an even number of bytes?

    I have been examining my files and have found that the size on disk always turns out even even when size is not even.
    Would this mess up my program if it created a file with an odd number of chars?
    Last edited by Once-ler; 03-02-2013 at 03:51 AM.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Nov 2011

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    It may seem that way probably because the file is optimized for easier disk storing, for example the minimum "on disk" size my files have are 4 KBytes. This may also vary for different file systems.
    Devoted my life to programming...

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    There's a difference between logical file size and physical file size. The logical size may be any number, odd or even, from 0 to as big as the file system allows. The logical size is a multiple of the size of a disk sector.
    Note also that it may not necessarily be greater than or equal to the physical size. Compressed files may have a smaller physical size than their logical size.

    If the size is always even then that could be an indication that your files are UTF16 for example.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Examining MBR and Printing Total Disk Size in Bytes
    By pantherman34 in forum C Programming
    Replies: 8
    Last Post: 04-30-2010, 03:27 PM
  2. hard disk serial number
    By vijayaroli in forum Windows Programming
    Replies: 1
    Last Post: 08-31-2006, 03:00 AM
  3. how to find volume serial number of disk using c
    By sudhirn in forum C Programming
    Replies: 0
    Last Post: 03-11-2004, 09:50 AM
  4. getting disk size information
    By Turek in forum C++ Programming
    Replies: 5
    Last Post: 07-31-2002, 02:52 AM
  5. Need help discovering disk-size
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-17-2001, 02:43 PM