here s is an array of 4 character pointers. so when you refer an array by base name, it decays to a pointer to the first element . hence basename s is char **.
so ptr is a pointer to the first element of the array. when you dereference it with a *, you get the value stored in the first element of the array, which is the pointer to the first string "miller". The prefix ++, increments this pointer by 1. since the data type is char *, the pointer is incremented to point the next byte(second char of the string "miller"). and the first printf prints "iller"
In the second printf postfix ++ has more precedence than *. so it increments ptr to point to second element of s. but remember, this side effect is applicable only after a sequence point. so the *ptr, still yields the value at the first element of s.
when control comes to the third ptr, ptr is pointing to the second elemtn of s. here we do a normal dereference to get the address of the second string "miller", and increment it by a char. so this also prints "iller".
The third and fourth string "filler" are really fillers as the name implies.
|
Recent comments
1 day 5 hours ago
1 day 5 hours ago
1 day 10 hours ago
1 day 16 hours ago
1 day 17 hours ago
1 day 18 hours ago
1 day 23 hours ago
2 days 5 hours ago
2 days 9 hours ago
2 days 11 hours ago