Enumerate the basic data types in C so that the sizes can be easily accessed
Enumerate the basic data types in C so that the sizes can be easily accessed Is it possible to get sizes of all basic datatypes in C using a for loop? For example, can we do something like this? #include <datatypes.h> /* or something else which defines get_data_types() */ #include <stdio.h> int main() { for (int x = 0; x < len(get_data_types()); x++) { printf("Size of %s is %d", get_data_types()[x], sizeof(get_data_types()[x])); } } I could enumerate all the datatypes by replacing the for loop and writing individual statements for int , long , etc. However, I am wondering if it is possible to have a for loop to do the same? int long Essentially, I am trying to avoid the following: #include <stdio.h> int main() { printf("Size of int is %d", sizeof(int); printf("Size of unsigned int is %d", sizeof(unsigned int); printf("Size of long is %d", sizeof(long); /* etc. */ return 0; } Data types of ...