Why is it adjacent memorey addresses differ by 4?
Attachment 10887
Printable View
Why is it adjacent memorey addresses differ by 4?
Attachment 10887
The "memory content" column is showing values which are four bytes in length, and your question is, why are the associated addresses differing by four bytes each time?
Can you put in words, what you think this chart is displaying?
Gee, I dunno, because the value being stored is 4 bytes long?
What do you get back?Code:printf("%d", sizeof(int));
Unless you are on some seriously old and outdated compiler, it will print 4 ... so in order to store 1 int you need 4 bytes of memory... thus one variable every 4 bytes... just like your image.
Whatever is stored in memory is 1s and 0s, so it really doesn't contain any information about what length data stored is.
In other words, it's showing them grouped by 4 bytes simply because you told it to do so. You can change that to other things (typically to a multiple of a byte).