Systemnahe Programmierung in C: Der sizeof-Operator |
1#include <stdio.h>
2
3enum color {red, green, blue};
4
5int
6main (void)
7{
8 printf ("TYPE\t\t\tSIZE\n\n");
9
10 printf ("char\t\t\t%d\n", (int)sizeof (char));
11 printf ("short\t\t\t%d\n", (int)sizeof (short));
12 printf ("int\t\t\t%d\n", (int)sizeof (int));
13 printf ("long\t\t\t%d\n", (int)sizeof (long));
14 printf ("enum color\t\t%d\n\n", (int)sizeof (enum color));
15
16 printf ("float\t\t\t%d\n", (int)sizeof (float));
17 printf ("double\t\t\t%d\n", (int)sizeof (double));
18 printf ("long double\t\t%d\n\n",(int)sizeof (long double));
19
20 printf ("char *\t\t\t%d\n", (int)sizeof (char *));
21 printf ("int *\t\t\t%d\n", (int)sizeof (int *));
22
23 return 0;
24}
|
Letzte Änderung: 22.11.2012 | © Prof. Dr. Uwe Schmidt |