预期’;’在声明列表c的末尾,当我已经有一个
发布时间:2020-12-16 10:01:11 所属栏目:百科 来源:网络整理
导读:我试图在一个名为bread的结构中声明和数组,但它一直给我错误预期’;’在我已经拥有一份声明清单的最后. typedef struct{ char bread[9][35] = { "1. 9-Grain Wheat","2. 9-Grain Honey Oat","3. Italian","4. Italian Herbs Cheese","5. Flatbread (not bake
我试图在一个名为bread的结构中声明和数组,但它一直给我错误预期’;’在我已经拥有一份声明清单的最后.
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; 这是结构所在的头文件的内容 解决方法
您无法初始化typedef中的结构.定义该类型的变量时必须这样做:
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","9. Roasted Garlic" }}; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |