Im trying to declare and array in a structure called bread, but it keeps giving me the error expected ';' at end of declaration list when i already have one.
typedef struct
{
char bread[9][35] = {
"1. 9-Grain Wheat",
"2. 9-Grain Honey Oat",
"3. Italian",
"4. Italian Herbs & Cheese",
"5. Flatbread (not baked in restaurant)",
"6. Cheese Bread",
"7. Hearty Italian",
"8. Parmesan Oregano",
"9. Roasted Garlic" };
} subway;
this is the contents of the header file the structure is in
You can't initialize a structure in a typedef
. You have to do it when you define a variable of that type:
typedef struct
{
char bread[9][50]; // the longest string is 38 characters, so the second dimension
// should be at least 39 (38 plus the null terminating byte)
// we'll round up to 50 to leave space for expansion
} subway;
subway s = {{
"1. 9-Grain Wheat",
"2. 9-Grain Honey Oat",
"3. Italian",
"4. Italian Herbs & Cheese",
"5. Flatbread (not baked in restaurant)",
"6. Cheese Bread",
"7. Hearty Italian",
"8. Parmesan Oregano",
"9. Roasted Garlic"
}};
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