c专家编程中一段,玩转数组
/************************************************************************* > File Name: array.c > Author: zhaozhi > Mail: zhaozhi0810@qq.com > Created Time: Tue 12 Feb 2013 10:35:52 AM CST ************************************************************************/
#include <stdio.h> #include <stdlib.h>
char array[]="abcdefghijklmn";
void my_array_func(char ca[5]) { printf("ca address = %#x\n",&ca); printf("ca[0] address = %#x\n",&(ca[0])); printf("ca[1] address = %#x\n",&(ca[1])); printf("++ca address = %#x\n",++ca); }
void my_point_func(char* ptr) { printf("ptr address = %#x\n",&ptr); printf("ptr[0] address = %#x\n",&(ptr[0])); printf("ptr[1] address = %#x\n",&(ptr[1])); printf("++ptr address = %#x\n",++ptr); }
int main(int argc,char * argv[]) { printf("array address = %#x\n",&array); printf("array[0] address = %#x\n",&(array[0])); printf("array[1] address = %#x\n",&(array[1])); // printf("++array address = %#x\n",++array);
printf("\n\n"); my_array_func(array); printf("\n\n"); my_point_func(array); printf("\n\n");
return 0;
}
./a.out array address = 0x80498f4 array[0] address = 0x80498f4 array[1] address = 0x80498f5
ca address = 0xbf98d600 ca[0] address = 0x80498f4 ca[1] address = 0x80498f5 ++ca address = 0x80498f5
ptr address = 0xbf98d600 ptr[0] address = 0x80498f4 ptr[1] address = 0x80498f5 ++ptr address = 0x80498f5
|