wbooze

maximum int

Apr 12th, 2022 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <limits.h>
  5.  
  6. int main(void)
  7. {
  8. long int *p;
  9.  
  10. /*
  11. * malloc() always provides aligned memory.
  12. * Do not use stack variable like a[9], depending on the compiler you use,
  13. * a may not be aligned properly.
  14. */
  15. p = malloc(sizeof(long int));
  16.  
  17. memset(p,0,8);
  18. *p = 0x7fffffffffffffffL;
  19. printf("%ld\n\n", *p);
  20.  
  21. printf("Size of int:%zd\n", sizeof(int));
  22. printf("Size of unsigned int:%zu\n", sizeof(unsigned int));
  23. printf("Size of long int:%zd\n", sizeof(long int));
  24. printf("Size of long long int: %zd\n\n", sizeof(long long int));
  25.  
  26. printf("INT_MAX=%d\n", INT_MAX);
  27. printf("UINT_MAX=%u\n", UINT_MAX);
  28.  
  29. printf("LONG_MAX=%ld\n", LONG_MAX);
  30. printf("ULONG_MAX=%lu\n", ULONG_MAX);
  31.  
  32. printf("LLONG_MAX=%lld\n", LLONG_MAX);
  33. printf("ULLONG_MAX=%llu\n", ULLONG_MAX);
  34.  
  35. return 0;
  36. }
  37.  
  38.  
Add Comment
Please, Sign In to add comment