Mail Archives: djgpp/1998/01/22/08:19:36
Scott Warner wrote:
>
> something like
>
> #include<stdio.h>
>
> int main(void)
> {
> int i;
> char c;
> float f;
>
> printf("Size of integer: %d\n", sizeof(i);
> printf("Size of char: %d\n", sizeof(c);
> printf("Size of float: %d\n", sizeof(f);
>
> return 0;
> }
>
you don't need to declare any variables. sizeof(type) is a constant
expression of size_t. incidentally, did you try to compile the above
with -Wall?
printf("Size of integer: %lu\n", sizeof(int);
printf("Size of char: %lu\n", sizeof(char);
printf("Size of float: %lu\n", sizeof(float);
etc. is fine.
> (and so on) is the general idea. I believe sizeof(int) is equivelant > to sizeof(i) in the above. WORD and DWORD (and the like) are most
> likely preprocessor macros that you can find if you look carefully
> through the header files.
people (e.g. Ralph Brown's interrupt list) generally use WORD to mean
16-bits and DWORD to mean 32-bits, contradicting the convention that a
machine word is that computer's natural int size.
--
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA
mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/
- Raw text -