Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(C++) INT_MAX and INT_MIN could not be resolved?

Tags:

c++

I am currently taking a C++ course on www.udemy.com In one of the lessons the teacher is using #include <limits> to demonstrate the maximum number of integers an integer can have. However, when I go to include limits, everything goes well until I try to print INT_MAX and INT_MIN to see the maximum integers and the minimum integers. Here is my code:

#include <iostream>
#include <limits>

using namespace std;

int main() {

    cout << "MaxInt= " << INT_MAX << endl;
    cout << "MinInt = " << INT_MIN << endl;
    return 0;
}

Side note: I am using Eclipse Neon CDT on Windows 10 with the MinGW Compiler.

like image 867
Jake Ramos Avatar asked Nov 20 '16 04:11

Jake Ramos


People also ask

What is INT_MAX and INT_MIN?

INT_MAX is a macro that specifies that an integer variable cannot store any value beyond this limit. INT_MIN specifies that an integer variable cannot store any value below this limit. Values of INT_MAX and INT_MIN may vary from compiler to compiler.

Where is INT_MAX defined in C++?

The INT_MIN and INT_MAX macros are the C way to get the maximum and minimum values of an int , and are defined in the "climits" header. The "limits" header defines the class template std::numeric_limits , which is the C++ way of getting the range of various types.

What is the meaning of INT_MAX?

INT_MAX is a macro which represents the maximum integer value. Similarly, INT_MIN represents the minimum integer value. These macros are defined in the header file <limits.


1 Answers

You want #include <climits> or <limits.h>, not <limits>.

like image 57
Waxrat Avatar answered Oct 23 '22 12:10

Waxrat