How to check endian-ness of CPU

4.72K viewsProgrammingalgorithms computing CPU programming
0

How do I check the endian ness of my CPU ?

Answered question
0

C program to do the same

 #include <stdio.h>
int main() {
    int number = 0x1234;
    char * c_ptr = (char * ) & number;
    if (c_ptr[0] == 0x34) {
        printf(“CPU is Little Endian\ n”);
    } else {
        printf(“CPU is Big Endian\ n”);
    }
    return 0;
}

Edited answer
Write your answer.

Categories