🎴 Flashcard Mode

C Programming Fundamentals

Card1 / 23
Mastered0
Review0
QuestionClick to flip

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

AnswerClick to flip back
A
fg
💡 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.

Change Mode