C | String | Question 6

int main()
    char str[] = "GeeksQuiz";
    printf("%s %s %s\n", &str[5], &5[str], str+5);
    printf("%c %c %c\n", *(str+6), str[6], 6[str]);
    return 0;

(A) Runtime Error
(B) Compiler Error
(C) uiz uiz uiz
u u u
(D) Quiz Quiz Quiz
u u u

Answer: (D)

Explanation: The program has no error. All of the following expressions mean same thing
Since compiler converts the array operation in pointers before accessing the array elements, all above result in same address.

Similarly, all of the following expressions mean same thing.

My Personal Notes arrow_drop_up

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.