I have the following code in C
#include <stdio.h>
char *gstr[] = { "Hello", "World" };
void func(char str[][8]) {
printf("%p
", (void *)str);
printf("%p
", (void *)(str + 1));
printf("%s
", *(str + 1));
}
int main(void) {
printf("%p
", (void *)gstr);
printf("%p
", (void *)(gstr + 1));
printf("%s
", *(gstr + 1));
printf("Calling Function
");
func(gstr);
return 0;
}
The following is the output
0x556f11ddd010
0x556f11ddd018
World
Calling Function
0x556f11ddd010
0x556f11ddd018
$??oU
I cannot understand why printf("%s
", *(str+1));
in the function func
does not print the string world
.