Data types

This is a discussion on Data types within the C Programming forums, part of the General Programming Boards category; This is a doubt that i had from a long time. First: a char, is it always one byte? or ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    58

    Data types

    This is a doubt that i had from a long time.

    First:
    a char, is it always one byte? or does it vary?

    Second: Is there any way to declare a type, say int32, that it's always a 32-bit integer on any architecture?

    Thank you.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by Govalant View Post
    a char, is it always one byte? or does it vary?
    It is always one byte, yes. But the language allows that a char/byte be defined at least 8 bits if not more.

    Quote Originally Posted by Govalant View Post
    Is there any way to declare a type, say int32, that it's always a 32-bit integer on any architecture?
    In C99 such things are available but optional, as intN_t. They may be found in <stdint.h>.

    See also 7.18.1.1.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    8
    Too slow :P

    ^^
    Last edited by stickmangumby; 06-04-2007 at 09:53 PM. Reason: see Dave_Sinkula's post above for answer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 04:28 PM
  2. Replies: 4
    Last Post: 06-14-2005, 06:45 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 07:26 PM

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