Advertisement
DrAungWinHtut

pointerarray.c

Apr 12th, 2023
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. void printIntArray(int *ip,int count);
  3.  
  4. int main() {
  5.  
  6.     int a[5]={3,5,2,7,9};
  7.     printf("a = %x\n",a);
  8.     printf("add of a[0] = %x\n",&a[0]);
  9.     int* ap = a;
  10.     printf("ap = %x\n",ap);
  11.     printf("value in ap = %d\n",*ap);
  12.     *ap=22;
  13.     printf("new value in ap %d\n",*ap);
  14.     printf("a array is...\n");
  15.     printIntArray(a,5);
  16.     ap+=3;
  17.     printf("ap = %x\n",ap);
  18.     printf("value in ap = %d\n",*ap);
  19.     printf("one data size is %d units\n",ap-a);
  20.     printf("size of int is %d bytes\n",sizeof(int));
  21.     return 0;
  22. }
  23.  
  24.  
  25. void printIntArray(int *ip,int count)//int * ip = a; int count = 5;
  26. {
  27.     for(int i=0;i<count+7;i++)
  28.     {
  29.         printf("index = %d value = %d\n",i,*ip);
  30.         ip++;
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement