How to move double array pointer

515 Views Asked by At

I am new to pointers, so please ignore my terminology mistakes. I have tried different operations like ++**ptr and *++*ptr to move pointer to next element in array but they don't have any effect.

#include<stdio.h>
#include<conio.h>

void main(){
    int a[] = {0,1,2,3,4};
    int *p = a;
    int **ptr = &p;
    clrscr();
    
    // To know the value
    printf("%d\t%d\t%p\t%p\t%p\n",*p,**ptr,*ptr,ptr,&p);
    
    //trying to understand this operation 
    **ptr++; 
    printf("%d\n",**ptr); //here for **ptr it should print 1 but printing 0 only

    *++*ptr; 
    printf("%d.",**ptr);//here for **ptr it should print 2 but printing 0 only
    
    getch();
}

Also rather than doin int *p = a; , can I do int *p[] = {a,a+1,a+2,a+3,a+4};

0

There are 0 best solutions below