指针数组地址连续否?
#include "iostream.h"void main()
{ int i;
char *week1[7]={"Sunday","Monday","Tuesday","Wednesday","Thusday","Friday","Saturday"};
char *week2[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thusday","Friday","Saturday"};
cout<<"char *week[7]:\n week="<<week1<<endl;
for(i=0;i<7;i++)
cout<<&week1[i]<<" "<<(void *)week1[i]<<" "<<strlen(week1[i])<<endl;
cout<<"char *week[7][10]:\n week="<<week2<<endl;
for(i=0;i<7;i++)
cout<<&week2[i]<<" "<<(void *)week2[i]<<endl;
}
运行后见图片:
问题:
week1中指针的地址为什么不是按照void *week1[i+1]=void *week1[i]+strlen(week1[i])+1递增!
难道占内存地址不是连续的?