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]

24th Feb 2019, 3:46 PM
Sandeep Mehta
Sandeep Mehta - avatar
2 Respostas
+ 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.
24th Feb 2019, 8:48 PM
Yusuf
Yusuf - avatar