How to check endian-ness of CPU

1.58K 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
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.

Categories