A
arnuld
#include <stdio.h>
int main( void )
{
char arrc[] = { 'a', 'b', 'c', '\0' };
char* pc = arrc;
char** ppc = &pc;
printf("arrc = %s\n", arrc);
printf("------------------------\n");
printf("*pc = %5c\n", *pc);
printf("**ppc = %5c\n", **ppc);
printf("++*pc = %5c, *pc = %5c\n", ++*pc, *pc);
printf("(**ppc)++ = %5c, **ppc = %5c\n", (**ppc)++, **ppc);
return 0;
}
===================== OUTPUT ==========================
[arnuld@dune ztest]$ gcc -ansi -pedantic -Wall -Wextra ok.c
[arnuld@dune ztest]$ ./a.out
arrc = abc
------------------------
*pc = a
**ppc = a
++*pc = b, *pc = a
(**ppc)++ = b, **ppc = b
[arnuld@dune ztest]$
I am little confused at the output. after ++*pc , the *pc should print
'b', not 'a'. Same for **ppc, which is again printing the same element
even after having gone through a ++.
int main( void )
{
char arrc[] = { 'a', 'b', 'c', '\0' };
char* pc = arrc;
char** ppc = &pc;
printf("arrc = %s\n", arrc);
printf("------------------------\n");
printf("*pc = %5c\n", *pc);
printf("**ppc = %5c\n", **ppc);
printf("++*pc = %5c, *pc = %5c\n", ++*pc, *pc);
printf("(**ppc)++ = %5c, **ppc = %5c\n", (**ppc)++, **ppc);
return 0;
}
===================== OUTPUT ==========================
[arnuld@dune ztest]$ gcc -ansi -pedantic -Wall -Wextra ok.c
[arnuld@dune ztest]$ ./a.out
arrc = abc
------------------------
*pc = a
**ppc = a
++*pc = b, *pc = a
(**ppc)++ = b, **ppc = b
[arnuld@dune ztest]$
I am little confused at the output. after ++*pc , the *pc should print
'b', not 'a'. Same for **ppc, which is again printing the same element
even after having gone through a ++.