Pergunta de entrevista da empresa Technosoft Engineering

He asked me to solve this question: //Big Endian / Little Endian format example //Start byte address - 0x0100 //Data(int) - 0xabcdef01 //store in Little endian format and print the data.,

Resposta da entrevista

Sigiloso

2 de jun. de 2026

The interviewer explained me the question really well and gave me hints. I couldn't solve it, but the answer is: #include #include int main() { uint32_t data = 0xABCDEF01; // Point to the first byte of data uint8_t *p = (uint8_t*)&data; printf("Stored in Little Endian format:\n"); for (int i = 0; i < 4; i++) { printf("Address 0x%04X : 0x%02X\n", 0x0100 + i, *(p + i)); } // Reconstruct the value using pointer arithmetic uint32_t reconstructed = (*(p + 0) << 0) | (*(p + 1) << 8) | (*(p + 2) << 16) | (*(p + 3) << 24); printf("\nReconstructed value = 0x%X\n"