I thought I understood how memory works until I run this code, is memory backwards ? or I'm missing something ?
Code:
#include <stdio.h>
int main()
{
int a = 0x12345678;
char *c = (char *)&a;
for (int i = 0; i < 4; i++)
{
printf("c[%d]=%x \n", i, *(c + i));
}
return 0;
}
Output:
c[0]=78
c[1]=56
c[2]=34
c[3]=12