Quantcast
Viewing all articles
Browse latest Browse all 8

二维数组的内存结构

#define __LEN_NAME 8
#define __COUNT 4
struct tagTem
{
char nameList[__COUNT][__LEN_NAME];
};
#include <cstdlib>
#include <cstring>
int main()
{
tagTem tem;
memset(&tem, NULL, sizeof(tem));
int i = 0;
for (int y = 0; y < __COUNT; y++)
{
for (int x = 0; x < __LEN_NAME; x++)
{
tem.nameList[y][x] = x + (y << 4);
}
}


0x0018F6F0  00 01 02 03 04 05 06 07  ........
0x0018F6F8  10 11 12 13 14 15 16 17  ........
0x0018F700  20 21 22 23 24 25 26 27   !"#$%&'
0x0018F708  30 31 32 33 34 35 36 37  01234567
所以二维数组定义的时候是这样:char array[y][x];
原来之前我一直理解错了。。。
Image may be NSFW.
Clik here to view.


Enic 2016-07-08 16:05 发表评论

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>