Home »
C++ programming language
SCHAR_MAX constant with example in C++
C++ SCHAR_MAX constant: Here, we are going to learn about the SCHAR_MAX macro constant of climits header in C++.
Submitted by IncludeHelp, on May 01, 2019
C++ SCHAR_MAX macro constant
SCHAR_MAX constant is a macro constant which is defied in climits header, it is used to get the maximum value of a signed char object, it returns the maximum value that a signed char object can store, which is 127.
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 SCHAR_MAX constant is defined in both of the libraries.
Syntax
Syntax of SCHAR_MAX constant:
SCHAR_MAX
Sample Input and Output
Constant call:
cout << SCHAR_MAX;
Output:
127
Example 1
C++ code to demonstrate example of SCHAR_MAX constant with climits header:
// C++ code to demonstrate example of
// SCHAR_MAX constant with climits header
#include<iostream>
#include<climits>
using namespace std;
int main()
{
//prinitng the value of SCHAR_MAX
cout<<"SCHAR_MAX: "<<SCHAR_MAX<<endl;
return 0;
}
Output
SCHAR_MAX: 127
Example 2
C++ code to demonstrate example of SCHAR_MAX constant with limits.h header file:
// C++ code to demonstrate example of
// SCHAR_MAX constant with <limits.h> header file
#include<iostream>
#include<limits.h>
using namespace std;
int main()
{
//prinitng the value of SCHAR_MAX
cout<<"SCHAR_MAX: "<<SCHAR_MAX<<endl;
return 0;
}
Output
SCHAR_MAX: 127