The General, who is a five star manager, is conducting a code review with his test developers. “I’m looking at your code here boys. I do very much admire your use of union utterings,” he says.
#include <stdio.h>
union yankee {
int bulletInt;
float bulletFloat;
};
int main() {
union yankee soldier;
soldier.bulletInt = 111;
printf("Int: %i\n", soldier.bulletInt);
soldier.bulletFloat = 222.333333;
printf("Float: %f\n", soldier.bulletFloat);
/* clobbered by the float as expected */
printf("Int: %i\n", soldier.bulletInt);
return 0;
}
He continues, “However, I am a Yankee soldier with sympathetic tendencies towards the southern cause. We’uns don’t put on our best suits when we go out and kill hogs; therefore, I do declare that we abolish the union in such a rightly manner as prescribed here.”
#include <stdio.h>
union yankee {
int bulletInt;
float bulletFloat;
};
typedef union yankee confederate;
int main() {
confederate soldier;
soldier.bulletInt = 111;
printf("Int: %i\n", soldier.bulletInt);
soldier.bulletFloat = 222.333333;
printf("Float: %f\n", soldier.bulletFloat);
/* clobbered by the float as expected */
printf("Int: %i\n", soldier.bulletInt);
return 0;
}
















Recent Comments