摘要: 下段代码的运行结果:main(){ int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d",*(a+1),*(ptr-1));}答:2,5 *(a+1)就是a[1],*(ptr-1)就是a[4],执行结果是2,5 &a+1不是首地址+1,系统会认为加一个a数组的偏移,是偏移了一个数组的大小(本例是5个int) int *ptr=(int *)(&a+1); 则ptr实际是&(a[5]),也就是a+5原因如下: &a是数组指针,其类型为 int (*)[5]; 而指针加1 阅读全文
posted @ 2011-05-03 15:40 Fannic 阅读(1760) 评论(2) 推荐(2) 编辑
摘要: 字符串常用方法int main (int argc, const char * argv[]){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // 字符串的创建和初始化 NSString* sFormat = [[NSString alloc] initWithFormat:@"Year:%d", 2009]; NSString* sString = [[NSString alloc] initWithString:sFormat]; NSString* sTmp = nil; // 获取长度 N 阅读全文
posted @ 2011-05-03 09:16 Fannic 阅读(3034) 评论(0) 推荐(0) 编辑