how do you declare a union with a defined union?
declaring union
Collapse
X
-
ok so if i write it like this
#include <stdio.h>
typedef union
{
int a;
char b;
}data;
union data data1;
is it fine?
the ques was actually this
Define a union that can store both char and int type data values. You need to define that in a way such that later, the union name can be used as a data type itself. Declare another union of the same constitution using the previously defined Union.
Sorry but m totally new to C and home based student so having a lot of problem studying myself ..... sorry for asking too many quesComment
-
Originally posted by stdvudefine that in a way such that later, the union name can be used as a data type itself.
data unioninstance
(because of the typedef, "data" can be used as a type in itself and doesn't need to be preceded by the "union" keyword.)Comment
Comment