Thread: How to identify the end of array

  1. #16
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Interesting, and I stand corrected.

    But it seems the C standard implies that char is always one byte, whether it's 8 bits or 16 bits or 32 bits, since the size of every type is measured against char, and char is defined as 1 byte.

    Then we have in section 3.6:

    byte

    addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
    which is basically what char is. It seems that the standard uses char and byte more or less interchangeably, even if char (and therefore C's "byte") is much larger than what has ever historically been called a "byte" (I only know about "byte" being defined as 6, 7, or 8 bits at various points in time).

  2. #17
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    The hardware controls how many bits are in a byte, and yes, there may be some systems where the byte has more than 8 bits.

    In C, there is no difference between a char and a byte, other than there is no "byte" data type. The word, byte, is used as a generic term to describe a single unit of memory.

    Most hosted Operating Systems in current use, Windows, Mac, UNIX, Linux, and possibly others, use a byte of 8 chars. Forget history. We are in the 21st century. Let's move on.

  3. #18
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    In my previous post:
    use a byte of 8 chars.
    should be:
    use a byte of 8 bits.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. identify bug in code
    By acpower in forum C Programming
    Replies: 1
    Last Post: 06-17-2012, 07:02 AM
  2. Need help. Can't identify error.
    By bummielove in forum C Programming
    Replies: 23
    Last Post: 07-05-2011, 06:06 AM
  3. can you identify this car?
    By axon in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-19-2004, 02:59 PM

Tags for this Thread