Thread: How to get m/c size

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    How to get m/c size

    Hi guys/gals,
    I want to get the m/c size i.e., whether it is 16/32/64 bits. Is there any function in C to get the above information. I'm using Turbo C on DOS.

    Regards,
    Aamir

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What exactly is the "m/c"? Since you're using Turbo C, an int will be 16 bits. If you're trying to find the size of a variable type, you use the sizeof operator.
    Code:
    printf("The size of an int is %d.\n", sizeof( int ) );
    Otherwise, you'll need to specify exactly what you're talking about.

    PS: Get a new compiler.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    3
    i want to get the machine (i.e., Processor) size.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > i want to get the machine (i.e., Processor) size.
    About 3" square, using a ruler.
    Seriously, you're not going to work out the word size of a new processor using an old fossil of a compiler like that.

    Not that a new compiler would help. You can only assume that the compiler writer has chosen a word size which is "optimal" for the machine it is running on, but there's no guarantee of that.

    sizeof(int) is about the best you can do, but if you persist in using some old compiler, then your anwer is already wrong.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of array
    By goran00 in forum C Programming
    Replies: 38
    Last Post: 04-02-2008, 09:57 AM
  2. Pointer Size Relative To Integers?
    By SMurf in forum C Programming
    Replies: 1
    Last Post: 04-18-2006, 06:58 AM
  3. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 11:27 AM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM