RicardasSim

check endianness

Feb 13th, 2019
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. int main(void)
  5. {  
  6.     int val = 1;
  7.  
  8.     //printf("%s\n",*(char*)&val == 0 ? "big-endian" : "little-endian");  
  9.  
  10.     if(*(char*)&val) printf("little endian\n");
  11.     else printf("big endian\n");
  12.    
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment