My program contains a structure containing two array members. I've called the structure to a void function within function parameters.
structure definition:
struct caketime
{
double baking_time [4]={20,75,40,30};
double prepare_time[4]={30,40,25,60};
};
The void function:
void prepareorder(struct caketime p) {
int i=0;
for (i=0;i<LIMIT;i++)
{
if(p.prepare_time[i]==25)
printf("Choclate");
else if (p.prepare_time[i]==30)
printf("Sponge Cake");
else if (p.prepare_time[i]==45)
printf("Meringue");
else if (p.baking_time[i]==60)
printf("Red_velvet");
}
}
When I compile this program, I get the errors described below:
In function 'prepareorder': error: 'struct caketime' has no member named 'prepare_time'
error: 'struct caketime' has no member named 'baking_time'
What seems to be the problem over here?
Try,
struct caketime
{
double baking_time[4];
double prepare_time[4];
};
instead of,
struct caketime
{
double baking_time [4]={20,75,40,30};
double prepare_time[4]={30,40,25,60};
};
You should not initialize the array elements inside the structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With