Differnce between uint16_t and an uint8 array

This is a discussion on Differnce between uint16_t and an uint8 array within the C Programming forums, part of the General Programming Boards category; Hi, can some one explain to me the difference between Code: uin16_t and an Code: uint8_t array[2] Thanks....

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    72

    Differnce between uint16_t and an uint8 array

    Hi, can some one explain to me the difference between
    Code:
    uin16_t
    and an
    Code:
    uint8_t array[2]
    Thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    It would probably be easier to list the similarities:
    • They are the same size.

    They differ in pretty much every other respect.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Thanks, so what is the better choice to store
    2 BCD bytes
    an
    uint16_t
    or an
    unit8_t array[2]
    ?

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,456
    2 uint8_t, because you have a byte, which is uint8_t and 2 of them.
    When you use bigger sizes, you have to deal with endianess. But if you use an array, you don't.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Quote Originally Posted by Elysia View Post
    2 uint8_t, because you have a byte, which is uint8_t and 2 of them.
    When you use bigger sizes, you have to deal with endianess. But if you use an array, you don't.
    Thanks for the reply, it's ok for me.

  6. #6
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    2 BCD bytes? Don't you mean 2 BCD nibbles? It would only take one byte to store.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,456
    Quote Originally Posted by evariste View Post
    Thanks for the reply, it's ok for me.
    That makes no sense whatsoever.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Quote Originally Posted by nonoob View Post
    2 BCD bytes? Don't you mean 2 BCD nibbles? It would only take one byte to store.
    NO I mean 2 BCD Bytes.

  9. #9
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Quote Originally Posted by Elysia View Post
    That makes no sense whatsoever.
    yes it make sense because i don't want to deal with endianess

Popular pages Recent additions subscribe to a feed

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