Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to find the maximum value of integer int?
How to find the maximum value of integer int?
Method 1, using memset () standard library function:

// -

# include & ltiostream & gt

Use namespace std

int main(void)

{

int max

char * p =(char *)& amp; max

memset(p,255,sizeof(int));

memset(p+3, 127, 1);

cout & lt& ltmax

Returns 0;

}

// -

Method 2: Use the standard predefined macro INT_MAX.

// -

# include & ltiostream & gt

# include & lt restrictions & gt

Use namespace std

int main(void)

{

cout & lt& ltINT _ MAX & lt& ltendl

Returns 0;

}

// -