I am getting this error and dont know what to do :
error: request for member 'Number' in something not a structure or union 22 | if(answer==user.choice.Number)
The program chould check if the user input is equal to one of the enum elements and then print the number or the string in the union
#include <stdio.h>
#include <string.h>
typedef enum{
Number = 1,
String = 2,
}eenum;
union data{
int x;
char str[10];
eenum choice;
};
void display(union data user)
{
int answer;
puts("Enter1 or 2:");
scanf("%d",&answer);
if(answer==user.choice.Number)
{
user.x = 5;
printf("%d\n",user.x);
}
else{
strcpy(user.str,"hello");
printf("%s\n",user.str);
}
}
int main() {
union data user;
display(user);
return 0;
}