C语言指针比较

#include stdio.hconst int MAX = 3;int main () {intvar[] = {10, 100, 200};inti, *ptr;/* let us have address of the first element in pointer */

编程学习网为您整理以下代码实例,主要实现:C语言指针比较,希望可以帮到各位朋友。

#include <stdio.h>

const int MAX = 3;

int main () {

   int  var[] = {10, 100, 200};
   int  i, *ptr;

   /* let us have address of the first element in pointer */
   ptr = var;
   i = 0;

   while ( ptr <= &var[MAX - 1] ) {

      printf("Address of var[%d] = %x\n", i, ptr );
      printf("Value of var[%d] = %d\n", i, *ptr );

      /* point to the prevIoUs location */
      ptr++;
      i++;
   }

   return 0;
}

本文标题为:C语言指针比较

基础教程推荐