Struct has no name

My program contains a structure containing two elements of an array. I called the structure the void function in the functional parameters.

structure definition:

struct caketime { double baking_time [4]={20,75,40,30}; double prepare_time[4]={30,40,25,60}; }; 

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 could be the problem here?

+7
source share
1 answer

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 elements of the array inside the structure.

+10
source

All Articles