char *x[5] = {"abc","def","ghi","jkl","mno"};
char *y[5] = {"123","456","789","101","102"};
struct hcode {
char *word;
}hcodes[5];
struct key {
int id;
char *word;
struct hcode *password;
}keytab[5];
int main () {
for(int i = 0 ; i < 5 ; i++) {
keytab[i].word = y[i];
keytab[i].id = i+1;
keytab[i].password = hcodes+i; //same as &hcodes[i];
keytab[i].password->word = x[i];
}
//word is coming from x array and password word from y array
struct key * ptr = keytab;//ptr points to keytab[0]
ptr++->password++->word++; //password word of keytab[0] incremented -
//123 now becomes 23, password of keytab[0] becomes 456,
//ptr now points to keytab[1]
printf("%s,",++ptr++->word); //ptr-> word is incremented and printed
//As per precedence rule, we get ++((ptr++)->word) and though ptr++ happens first, due to post increment, the effect will be visible only on the next use of ptr.
//which is 56. ptr is incremented to point to keytab[2]
printf("%s,",++ptr++->password++->word); //ptr->password->word is incremented
//and printed which is hi. ptr is incremented to point to keytab[3]
printf("%s,",++ptr++->word); //as before this prints 01. ptr points to keytab[4]
printf("%s\n",++ptr[0].password++->word); //ptr[0] = *(ptr); so, no is printed
return 0;
}