Home > Programming > Functions using the "C" programming language > example09.c

 

Previous

Next


/*
** In this example we demonstrate how to pass a UNION as function parameter
*/

#include <stdio.h>
#include <conio.h>

struct POINT {
    int x;
    int y;
};

union LONGTYPE {
    struct POINT p;
    long l;
};

/*
    Function prototype
*/
void print_UNION(union LONGTYPE);

void main(void)
{
    union LONGTYPE lt;
    lt.p.x=10;
    lt.p.y = 0;
    print_UNION(lt);
}

/*
** function print_UNION source code
*/
void print_UNION(union LONGTYPE lu)
{
    printf("x is %d\ny is %d\nl is %ld\n",lu.p.x,lu.p.y,lu.l);
}


© 2004 Jim Valavanis

Previous

Next

1