views:

418

answers:

2

Consider a computer that has a byte addressable memory organized in 32 bit words according to the big endian scheme. A program reads ASCII characters entered at a keyboard and stores them in successive byte locations, starting at location 1000. Show the contents of two memory words at locations 1000 and 1004 after the name "johnson" has been entered.

+2  A: 

Just convert each letter to hex using a handy ASCII table, and add them to memory sequentially. This renders easily as gorgeous ASCII graphics:

+------+--+--+--+--+
|0x1000|6A|6F|68|6E|
+------+--+--+--+--+

The last four bytes were left out, this is homework after all.

unwind
Your nice ASCII art painfully reminds me of my hours of dabbling with J which renders boxed values like this (http://www.jsoftware.com/help/dictionary/d010.htm).
Joey
@Johannes: Indeed. Reminds me of an answer of my own: http://stackoverflow.com/questions/897366/how-do-pointer-to-pointers-work-in-c/897414#897414
Stephan202
A: 

I think than words will have next values:

1000: 0x6a6f686e
1004: 0x736f6e00

'Cause of name contains only 7 characters, eight character is unknown, so last position (00) may have any value.

Victor Vostrikov
You're not playing the game Victor ;-D
pavium