tags:

views:

101

answers:

6

Possible Duplicates:
How would you set a variable to the largest number possible in C?
maximum value of int

I need to use the maximum integer value in my my code, but I don't want to explicitly write 4294967295. Is it defined somewhere?

+5  A: 

INT_MAX (for int) or UINT_MAX (for unsigned int) defined in <limits.h>

James McNellis
+2  A: 

Use limits.h:

#include <limits.h>

int maximum = INT_MAX;
GMan
+1  A: 

INT_MAX as defined in <limits.h>

tommieb75
+1  A: 
#include <limits.h>

INT_MAX
alxx
+2  A: 

There shall be a constant in limits.h, if I'm not mistaken it shall be INT_MAX

rano
+1  A: 

The include file stdint.h includes all different macros for the different integer types. In particular UINTMAX_MAX for uintmax_t.

Jens Gustedt