試代碼:
#
include
"stdafx.h"
#
include
<iostream>
#
include
<Windows.h>
using
namespace std;
static
void DelaySeconds(int Time);
int _tmain(int argc, _TCHAR* argv[])
{
char CharPointer[13] = {NULL};
char CharPointer1[13] = {NULL};
char CharPointer2[13] = {NULL};
short
int ShortIntPointer[13]
= {NULL};
int IntPointer[13] = {NULL};
long int LongIntPointer[13] = {NULL};
cout<<"CharPointer :"<<&CharPointer<<endl;
cout<<"CharPointer + 1:"<<CharPointer+1<<endl;
cout<<"CharPointer1 :"<<&CharPointer1<<endl;
cout<<"CharPointer2 :"<<&CharPointer2<<endl;
cout<<"ShortIntPointer :"<<&ShortIntPointer<<endl;
cout<<"ShortIntPointer + 1:"<<ShortIntPointer+1<<endl;
cout<<"IntPointer :"<<&IntPointer<<endl;
cout<<"IntPointer + 1 :"<<IntPointer+1<<endl;
cout<<"LongIntPointer :"<<&LongIntPointer<<endl;
cout<<"LongIntPointer + 1 :"<<LongIntPointer+1<<endl;
DelaySeconds(60);
return
0;
}
void DelaySeconds(int Time)
{
Sleep(Time*1000);
}
列印結果:
結果分析:從列印結果分析得出所有數組的首地址都是四位元組對齊