training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

checkunion.c (373B)


      1 /* Exercise 10.8 */
      2 
      3 #include <stdio.h>
      4 
      5 typedef union values {
      6    char c;
      7    short s;
      8    int i;
      9    long b;
     10 } List;
     11 
     12 int main(void)
     13 {
     14    List lval;
     15 
     16    printf("Char short int long: ");
     17    scanf("%c%hi%d%ld", &lval.c, &lval.s, &lval.i, &lval.b);
     18 
     19    printf("Char: %c\nShort: %hi\nInt: %d\nLong: %ld\n",
     20       lval.c, lval.s, lval.i, lval.b);
     21 
     22    return 0;
     23 } /* E0F main */
     24