2015-05-01 39 views
1

在下面的代碼中,卡片數組編號正常,但是一組會計沒有。爲什麼?有沒有辦法修復accts?未編譯的結構數組的初始化

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} }; 

}

+4

這些都不應該在C中工作。沒有'卡'或'會計'。只有'struct card'和'struct accountant'。請發佈*真實*代碼。 – WhozCraig

+3

在我看來,那些雙引號是非標準的。 –

+0

'會計師數組' - 可怕.. –

回答

9

您可能注意到,在「Josh」是不正常的引號。他們通常被稱爲智能報價,雖然他們看起來更好,但他們不是編譯器期望的。您是否從Microsoft Word(或類似軟件)複製粘貼了該文件?

將引號改爲"

+0

多麼愚蠢 - 是的你是正確的。我會關閉。 –

+0

@AngusComber沒有理由關閉你自己的問題AFAIK。 – immibis