Multiple choice

char *buffer = 0123456789; char *ptr = buffer; ptr += 5; printf( %s, ptr ); printf( %s, buffer );
What will be printed when the sample code above is executed?

  1. 0123456789 56789

  2. 5123456789 5123456789

  3. 56789 56789

  4. 0123456789 0123456789

  5. 56789 0123456789

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

The pointer ptr is incremented by 5, so it points to the character '5'. Printing ptr prints '56789'. Printing buffer prints the entire string '0123456789'.