#Meta-Wlp: #Macro: TITLE wlp: Learn C (IV) p. 9 #Eval: $TITLE$ #Macro: PAGE bb4-9

When ip equals z, the while loop terminates.

In C, pointers can be incremented, decremented, have integers added to them, and two pointers can be tested for equality.

Sometimes, two pointers can be subtracted, but they can never be added.

Is this the same program as the previous?

#include<stdio.h>

int count_backwards( int * z, int * ip ) {
   while (z!=ip) printf("%d, ", *ip-- ) ;
   printf("%d\n",*ip) ;
}

int main(){
  int my_count[3] ;
  my_count[0] = 0 ;
  my_count[1] = 1 ;
  my_count[2] = 2 ;
  count_backwards( my_count, my_count+2 ) ;
}
#Shuffle: none $PAGE$-A $PAGE$-B Return to Learn C Table of Contents #: Yes, it is the same. #: No, it is not the same. #: