Hi, I'm trying to do an exercise from the C programming language. It asks to create a program to find out the ranges of the data types from standard headers. I believe the header that holds these ranges is limits.h
The problem is I can't get proper results (btw I'm using slack's 10.0 default gcc)
In the header there is:
Code:
#define UCHAR_MAX 255
#ifdef __CHAR_UNSIGNED__
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#else
#define CHAR_MIN SCHAR_MIN
#define CHAR_MIN SCHAR_MAX
#endif.
Now in my program, I'm trying to do:
Code:
#define __CHAR_UNSIGNED__
printf("uchar:\t%d\t%d\n", CHAR_MIN, UCHAR_MAX);
printf("schar:\t%d\t%d\n", SCHAR_MIN, SCHAR_MAX);
But whenever I run the program I get [-128, 255] for unsigned char and [-128, 127] for signed.
The #define __CAHR_UNSIGNED__ has no effect? What is the proper solution?
Thanks for your time