Take a look at following code and output:
char *words[] = {"wehrmarcht", "collectorate", "hello", "hello","precorrection", "hello","wehrmarcht"};
char *wp;
cnode *np;
for(wp = *words; wp - *words < sizeof(words); wp += strlen(wp) + 1) {
printf("wp -> %s\n", wp);
}
printf("==============================================\n");
for(int i = 0; i < sizeof(words) / sizeof(char *); i++) {
printf("words[%d] -> %s\n", i,words[i]);
}
output:
wp -> collectorate
wp -> precorrection
wp -> wp -> %s
wp -> ==============================================
==============================================
words[0] -> wehrmarcht
words[1] -> collectorate
words[2] -> hello
words[3] -> hello
words[4] -> precorrection
words[5] -> hello
words[6] -> wehrmarcht
Process finished with exit code 0
Can someone explain what makes the wp points to some strings in code? Thanks in advance.
"hello"appears three times that would really mess up the supposition of a regular sequence.