C program to check little vs. big endian

阅读 19

2024-01-19

void main()
{
        int n = 1;
        // little endian if true
        if(*(char *)&n == 1)
                printf("This is little endian\n");
        else
                printf("This is big endian\n");
}

Suppose we are on a 32-bit machine.
And char type is 8 bits
在这里插入图片描述
在这里插入图片描述

相关推荐

精彩评论(0)

0 0 举报