Home » 
        C++ programming language
    
    
    CHAR_MIN constant with example in C++
    
    
    
    
        C++ CHAR_MIN constant: Here, we are going to learn about the CHAR_MIN macro constant of climits header in C++.
        
        Submitted by IncludeHelp, on May 01, 2019
        
    
    C++ CHAR_MIN macro constant
    CHAR_MIN constant is a macro constant which is defied in climits header, it is used to get the minimum value of a char object, it returns the minimum value that a char object can store, which is either -128 (SCHAR_MIN) or 0.
   
    Note:
    
        - The actual value depends on the compiler architecture or library implementation.
 
        - We can also use <limits.h> header file instead of <climits> header as CHAR_MIN constant is defined in both of the libraries.
 
    
    Syntax
    Syntax of CHAR_MIN constant:
CHAR_MIN
    Sample Input and Output
Constant call:
cout << CHAR_MIN;
Output:
-128
   
   Example 1
   C++ code to demonstrate example of CHAR_MIN constant with climits header:
// C++ code to demonstrate example of 
// CHAR_MIN constant with climits header
#include<iostream>
#include<climits>
using namespace std;
int main()
{
   //prinitng the value of CHAR_MIN
    cout<<"CHAR_MIN: "<<CHAR_MIN<<endl;
    return 0;
}
Output
CHAR_MIN: -128
    Example 2
    C++ code to demonstrate example of CHAR_MIN constant with limits.h header file:
// C++ code to demonstrate example of 
// CHAR_MIN constant with <limits.h> header file
#include<iostream>
#include<limits.h>
using namespace std;
int main()
{
   //prinitng the value of CHAR_MIN
    cout<<"CHAR_MIN: "<<CHAR_MIN<<endl;
    return 0;
}
Output
CHAR_MIN: -128
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement