Re: Find the size of a datatype



Keith Thompson opined:

"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.

You're right, of course. I should have said "your implementation's
documentation".

--
But what can you do with it? -- ubiquitous cry from Linux-user
partner.
(Submitted by Andy Pearce, ajp@xxxxxxxxxxxxxxxx)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

.



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, ... 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)