Mega Code Archive

 
Categories / C Tutorial / Data Type
 

Overflow in char and unsigned char data types

Overflow means you are carrying out an operation such that the value either exceeds the maximum value or is less than the minimum value of the data type. (Definition from C & Data Structures by P.S. Deshpande and O.G. Kakde Charles River Media 2004) #include <stdio.h> main() {     char i,j ;     i = 1;     while (i > 0){         j = i;         i++;     }     printf ("the maximum value of char is %d\n",j);     printf ("the value of char after overflow is %d\n",i); } the maximum value of char is 127 the value of char after overflow is -128