codeDom codeDom - 14 days ago 5
C Question

C - single quotes vs double quotes

I'm curious about this code:

int a = 'ftyp'; // a == 1718909296
int b = *((int*)"ftyp"); // b == 1887007846


My question: Why a != b ?

Answer

Like @Cornstalks wrote:

It's big endian vs little endian. It becomes more obvious when you use hex: a is 0x66747970 and b is 0x70797466.