/* Array and pointers */ #include #include int main() { int array1[] = {100,200,300} ; int* ptr1 ; //An array can be treated as a pointer //array1 = ptr1 ; ptr1 = array1 ; printf( "%d\n" , *ptr1 ) ; printf( "%d\n" , ptr1[0] ) ; printf( "%d\n" , *(ptr1+1) ) ; printf( "%d\n" , *array1 ) ; printf( "%d\n" , *(array1+1) ) ; // A pointer can be treated as an array. ptr1 = (int*)malloc( sizeof(int) * 10 ) ; *ptr1 = 10 ; *(ptr1+1) = 20 ; printf( "%d\n" , ptr1[0] ) ; printf( "%d\n" , ptr1[1] ) ; free ( ptr1) ; }