Multiple choice

char *ptr; char myString[] = abcdefg; ptr = myString; ptr += 5;
What string does ptr point to in the sample code above?

  1. fg

  2. efg

  3. defg

  4. cdefg

  5. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

ptr starts at index 0 pointing to 'a'. After ptr += 5, it points to index 5, which is 'f'. The string from that position is 'fg' (characters at indices 5 and 6). This is basic pointer arithmetic where the pointer moves forward by the specified number of elements.