#include #include #define ENTIER 0 #define FLOTTANT 1 typedef union { int entier; // 4 octets double flottant; // 8 octets } nombre; // 8 octets void afficher_nombre(nombre x, int type) { printf("Nombre = "); if (type == FLOTTANT) { printf("%lg\n", x.flottant); } else { printf("%d\n", x.entier); } } int main() { nombre x; x.entier = 5; x.flottant = 3.2; // on a écrasé l'entier afficher_nombre(x, FLOTTANT); afficher_nombre(x, ENTIER); return EXIT_SUCCESS; }