Can I check if union is null in c? For example:
union{ char * name, struct Something * something ... }someUnion;
Is there a way to check if no element has been initialized, without doing element vise check?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, under the conditions that all members of the union are of pointer type or a integral type and with initialization you mean a value which is not NULL has been assigned, it is sufficient to check one element for NULL.