0
Can anyone explain how this code works and what will be the output?
char str[] = "%d%c", arr[] = 'SoloLearn'; printf(str, 0[arr], 2[arr+3]
2 Answers
+ 2
arr[0] is same thing as 0[arr]
printf needs format operators for variables to be printed. It uses %d for ints and uses %c for characters.
Compiler will turn this function call into:
printf("%d%c", (int)'S', (char)'e');
%d will refer to ASCII value of 'S', %c will refer to 'e'.
You can guess output.