#include<stdio.h>
int main()
{
switch(*(1+"AB""CD"+1))
{
case'A':printf("Pulp Fiction");
break;
case'B':printf("12 Angry Man");
break;
case'C':printf("Casabance");
break;
case'D':printf("Blood Diamond");
}
return 0;
}
This is one C code and it gives output as per the third character in the given string . "AB""CD" gives Casabance , "AB""DD" gives Blood Diamond . I would like to know how the expression in the switch statement calculated ?
While , I tried another code,
#include<stdio.h>
int main()
{
const char ch=*(1+"AB""AD"+1);
printf("%c",&ch);
return 0;
}
This code gives a output 'f' for any changes i make to the string . I would like to know how this expression is evaluated ?
And why do both above codes differ ??