c-uebungen/Assignment_009/solution/sizeof.c

23 lines
893 B
C
Raw Permalink Normal View History

2023-05-21 21:10:46 +02:00
#include <stdio.h>
int main(int argc, char *argv[])
{
int array[] = { 1, 2, 3, 4, 5 };
char name[] = "Thomas";
printf("The size of a short is : %ld\n", sizeof(short));
printf("The size of an int : %ld\n", sizeof(int));
printf("The size of a long is : %ld\n", sizeof(long));
printf("The size of a long long is : %ld\n", sizeof(long long));
printf("The size of a float is : %ld\n", sizeof(float));
printf("The size of a double is : %ld\n", sizeof(double));
printf("The size of areas (int[]) : %ld\n", sizeof(array));
printf("The number of ints in array: %ld\n",
sizeof(array) / sizeof(int));
printf("The size of a char : %ld\n", sizeof(char));
printf("The size of name (char[]) : %ld\n", sizeof(name));
printf("The number of chars : %ld\n", sizeof(name) / sizeof(char));
return 0;
}