初始化不编译的结构数组

时间:2015-05-01 07:48:26

标签: c arrays

在下面的代码中,一组卡片编译正常,但一组会计师没有。为什么?有没有办法解决行为?

struct card {
    int value;
    int cost;
};

struct accountant
{
   const char* name;
   double salary;
};

int main() {

    card cards[] = { {1, 1}, {2, 2}, {3,3} };  // compiles ok

    // error C2065: '“Josh”' : undeclared identifier
    // error C2065: '“Kate”' : undeclared identifier
    // error C2065: '“Rose”' : undeclared identifier
    accountant accts[] = { {“Josh”, 2100.0}, {“Kate”, 2900.0}, {“Rose”,1700.0} };

}

1 个答案:

答案 0 :(得分:9)

您可能会注意到<input id="candidate_first_name" placeholder="Candidate First Name*" type="text" class="ui-input-shadow-text"> “Josh”不是正常的引号。它们通常被称为智能引号,虽然它们看起来更好,但它们并不是编译器所期望的。您是否从Microsoft Word(或类似)中复制粘贴?

将引号更改为