| Refresh | Home EGTry.com


//point and array
#include <stdio.h>

int main()
{

  int a[]={1,2,3};
  int ln;
  int *p; //the address of p is allocated, but the value of p is not defined
  int *p2;

  int i;

  ln=sizeof(a)/sizeof(int);
  printf("size of array %d\n", ln);
  p=a; 
  p2=&a[0];
  if (p==p2)
    printf("same %d", p);

  for(i=0; i<ln; i++)
  {
    printf("the a(%d)=%d\n", i, *p);
    p++;
  }

  return 0;
}