Загрузка данных


#include <stdio.h>

#define SIZE_OF(arr) ((char *)&(arr)[1] - (char *)&(arr)[0])

long long pow2(int n)
{
    long long r = 1;
    while (n--)
        r *= 2;
    return r;
}

#define S_LIMITS(type, name, fmt)                        \
    {                                                    \
        type arr[2];                                     \
        int bits = SIZE_OF(arr) * 8;                     \
        long long mx = pow2(bits - 1) - 1;               \
        printf(#name "_max=" fmt "\n", (type)mx);        \
        printf(#name "_min=" fmt "\n", (type)(-mx - 1)); \
    }

#define U_LIMITS(type, name, fmt)                                   \
    {                                                               \
        type arr[2];                                                \
        int bits = SIZE_OF(arr) * 8;                                \
        unsigned long long mx = (unsigned long long)pow2(bits) - 1; \
        printf("u" #name "_max=" fmt "\n", (type)mx);               \
        printf("u" #name "_min=0\n");                               \
    }

int main()
{
    S_LIMITS(char, char, "%d")
    S_LIMITS(short, short, "%d")
    S_LIMITS(int, int, "%d")
    S_LIMITS(long, long, "%ld")
    S_LIMITS(long long, long_long, "%lld")

    U_LIMITS(unsigned char, char, "%u")
    U_LIMITS(unsigned short, short, "%u")
    U_LIMITS(unsigned int, int, "%u")
    U_LIMITS(unsigned long, long, "%lu")
    U_LIMITS(unsigned long long, long_long, "%llu")

    return 0;
}