What will be printed during execution:

#include <iostream>

int main()
{
    int x[] = {3,5,8} ;
    std::cout << (*x)["my string"+3] ;
}
Explanation
Will be printed "i".
Dereferencing of "x" will give the value "x[0] == 3".
"my string" will be converted to a const pointer to a given string.
We will get the following: 3[pointer+3]
This expression, according to the language rules, will be converted to *(3+pointer+3).
Thereby in brackets,​ we will get the offset on 6 symbols in the string "my string" and while dereferencing will get const char with value "i"

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes