小编AJ *_*J J的帖子

struct没有名为的成员

我的程序包含一个包含两个数组成员的结构.我已经将结构称为函数参数中的void函数.

结构定义:

struct caketime
{
    double baking_time [4]={20,75,40,30};
    double prepare_time[4]={30,40,25,60};
};
Run Code Online (Sandbox Code Playgroud)

虚函数:

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");
    }
}
Run Code Online (Sandbox Code Playgroud)

当我编译这个程序时,我得到下面描述的错误:

In function 'prepareorder': error: 'struct caketime' has no member named 'prepare_time'
error: 'struct caketime' has no member named 'baking_time'
Run Code Online (Sandbox Code Playgroud)

这里似乎有什么问题?

c arrays function data-structures

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

c ×1

data-structures ×1

function ×1