// integral_error_test.c - fatal errors that can happen with
// integral datatypes.

char a_char_ = '\0';
unsigned char a_uchar_ = 0;
unsigned int a_uint_ = 0;

main()
{
  a_uchar_ = 'x';
  printf("a_uchar_ has the ASCII-value %u\n",a_uchar_);
  a_uint_ = a_uchar_;
  a_uint_ = a_uint_ + 300;
  printf("a_uint_ has the value %u\n",a_uint_);
  a_uchar_ = a_uint_; // overflow!!
  printf("after overflow a_uchar_ has the ASCII-value %u\n",
          a_uchar_);
  
  // signed - unsigned mix can be fatal:
  a_uchar_ = 200;
  a_char_ = a_uchar_;
  printf("a_uchar_ has the value %u\n",a_uchar_);
  printf("a_char_ has the value %d\n",a_char_);
  printf("interpreting a_char_ as unsigned it becomes %u\n",
         a_char_);
}