Nitin said:
Hi,
Without using sizeof, is there a way to get to know the size of any data
type on that OS ... ???
one way I could think of is to take diff of the addresses of two variables
defined consecutively.
Any other way .....????
thanks,
nitin
There is no method to find the size of an OS's data type or structure
without having a declaration or definition of that type. Operating
Systems may have many types that they use.
As others have said, use the "sizeof" operator. The "sizeof" operator
is generally a constant that is evaluated at compile-time. The
difference between the addresses of two consecutive objects is
platform dependent and may be expressed in units of the type of
that object. Casting to an unsigned char or placing the address
into an integer may cause problems. Addresses aren't guaranteed
to be convertable to an integer. Anyway, the difference computation
is a run-time issue.
Remember that there are more than three operating systems. Some
may have displays, others not. Make no assumptions about a
platform, except for what the Standard describes.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book