Recently re-learning "C and pointers", an example in the pointer that chapter-looking for a specific character in a string of strings: Version 2 has a sentence to see not quite understand, * (*string) + +, so write the program test, pondering a bit.
Test the program like this:
#include <stdio.h>int main () {char str1[] = "ABCD"; char str2[] = "EFGH"; char *pstrarray[2] = {str1, str2};char **ps TR1 = Pstrarray;char **pstr2 = Pstrarray; (*PSTR1) ++;*pstr2++;p rintf ("%c", **PSTR1);p rintf ("%c", **PSTR2); GetChar ();}
VS compile run, final print effect: B E
The second good understanding, the first result but suddenly do not understand, then the thinking of the misunderstanding is this:
After execution (*PSTR1) + + only *pstr1 changed, PSTR1 itself did not change, guess **pstr1 output should be a.
Now figured out, pStr1 really did not change, pStr1 inside is pstrarray[0] address, and Pstrarray[0] saved is str1[0] address, when (*PSTR1) + + is executed, that is equivalent to pstrarray[0]++, At this point pstrarray[0] points to str1[1], so the output of **PSTR1 is B.
The reason to enter the mistaken thinking is that *str1 equivalent to &pstrarray[0] is not obvious, thought is just a temporary variable, not saved is discarded, there is the suspicion of execution after pStr1 whether or not have been changed.
Some understanding of C language Level two pointers