max int in c code example
Example 1: string to int c
atoi(str) is unsafe
This is the prefered method:
(int)strtol(str, (char **)NULL, 10)
Example 2: How to define Max in define in c
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
Example 3: how to print int in c
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}
Example 4: max size for int c
-2,147,483,648 to 2,147,483,647
Example 5: int max in c++
2147483647
unsigned long long int = 18 446 744 073 709 551 615
Example 6: C largest unsigned int
The sizeof function will help you here.
sizeof(data type) returns a size_t
Example:
return sizeof(int)