试代码:
#
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);
}
# 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);
}
打印结果:
结果分析:从打印结果分析得出所有数组的首地址都是四字节对齐