I'm having trouble reading through a series of * and & operators in order to understand two lies of code within a method. The lines are:
int dummy = 1;
if (*(char*)&dummy) { //Do stuff
}
As best I can determine:
dummyis allocated on the stack and its value is set to1&dummyreturns the memory location being used bydummy(i.e. where the1is)(char*)&dummycasts&dummyinto a pointer to a char, instead of a pointer to an int*(char*)&dummydereferences(char*)&dummy, returning whatever char has a numeric value of1
This seems like an awfully confusing way to say:
if (1){//Do stuuf }
Am I understanding these lines correctly? If so, why would someone do this (other than to confuse me)?