If write(0x01234567) is called on an instance of output stream, what will be written to the destination of the stream?

971 views Asked by At

Hi,I have a question

If write(0x01234567) is called on an instance of output stream, what will be written to the destination of the stream?

a. The bytes 0x01, 0x23, 0x34, 0x45, and 0x67, in that order.

b. The bytes 0x67, 0x45, 0x34, 0x23, and 0x01, in that order.

c. The byte 0x01.

d. The byte 0x67.

e. None of the above.

I am getting "D" but answer "C"?, why? please explain

1

There are 1 answers

1
Milan On

The output can vary depends on machine, support byte ordering big endian or little endian. I think you ran the program on the machine that support little endian byte ordering that's why you getting 67.

Learn More: https://www.geeksforgeeks.org/little-and-big-endian-mystery/