letowianka
letowianka

Reputation: 484

How many bytes are stored at a memory address?

I am very confused with the following gdb output. I am debugging a program that processes a text file. The first word in the file is "the" and the gdb output looks as follows:

"The":

(gdb) p *(char*)0x7fffffff9d30
$12 = 84 'T'

(gdb) p *(char*)0x7fffffff9d34
$13 = 104 'h'

(gdb) p *(char*)0x7fffffff9d38
$14 = 101 'e'

A character is one byte, so when I increase the address of 'T' by 8 bits I should find 'h' there. But the address of 'h' is only 4 bits farther. What am I missing here?

Didn't realize that these are Wchar_t (wide characters).

Upvotes: 0

Views: 1016

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22529

FWIW, in situations like this you might like to use the "x" command to dump memory. This avoids any possible confusion caused by types and operators.

Upvotes: 1

Related Questions