Re: Find the size of a datatype



"Vladimir Oka" <novine@xxxxxxxxxxxxxxx> writes:
Rahul K wrote:
Hello all
Suppose I am given a datatype say X in C. How can i find its size
without declaring a variable or pointer variable of that type, and of
course without using sizeof operator.

Why "of course", and why without `sizeof`. That's what it's for, after
all.

One recourse remaining to you seems to be grepping/eyeballing for the
type definition in the code (or looking into the C Standard for
built-in types) and figuring it "manually".

That's not possible in general. No amount of looking into the C
standard will tell you how big an int is.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Find the size of a datatype
    ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... of course without using sizeof operator. ... standard will tell you how big an int is. ...
    (comp.lang.c)
  • Re: Find the size of a datatype
    ... Rahul K wrote: ... Suppose I am given a datatype say X in C. ... without declaring a variable or pointer variable of that type, ... course without using sizeof operator. ...
    (comp.lang.c)
  • Re: help me out
    ... the size of the datatype, without declaring a variable or a pointer ... variable of that type, And, of course without using sizeof operator! ...
    (comp.lang.c)
  • Re: help me out
    ... You are given have a datatype, ... without declaring a variable or a pointer ... variable of that type, And, of course without using sizeof operator! ... Any sane programmer would use sizeofso this must be homework. ...
    (comp.lang.c)
  • Re: Does C99 imply pointer subtraction is never portable?
    ... The standard doesn't state that explicitly, ... It says that the sizeof operator yields a result of type size_t. ... int yields a result of type int; that doesn't imply that the result ...
    (comp.std.c)