Skip to content

Commit 763f066

Browse files
authored
Code to find if system is Big or Little endian
CPP Code to find if system is Big or Little endian No extra libraries required
1 parent 80269e0 commit 763f066

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

endian.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <iostream>
2+
3+
int main(){
4+
union{
5+
uint32_t i;
6+
uint8_t c[4];
7+
}data;
8+
data.i= 0x01020304;
9+
if(data.c[0] == 0x01){
10+
std::cout<< "Big endian" <<std::endl;
11+
}else{
12+
std::cout<< "Little endian" <<std::endl;
13+
}
14+
}

0 commit comments

Comments
 (0)