2015-04-22 139 views
-3
#include <iostream> 
#include <iomanip> 
using namespace std; 
int main() 
{ 
    int i; 
    char s[10] = {'a' , 'b' ,'c' 'd' ,'e', 'f', 'g', 'g','h','i'}; 

    cout << "element" << setw(7) << "value " << endl; 
    for (i=0 ; i <10 ; i++) 
    cout << i << setw(7) << s[i] << endl; 

    return 0; 
} 

我想TP獲取列表就像爲什麼數組不打印列表?

element  value 
0    a 
1    b 
2    c 
3    d 
4    e 
5    f 
6    g 
7    g 
8    h 
9    i 

但是編譯器會發出錯誤.... 是否有任何人誰可以指出我的錯誤?

+2

你是那個需要指出你的錯誤,然後我們會告訴你什麼是問題。 –

+3

仔細閱讀錯誤消息,它會告訴你你忘了逗號的地方。 – Wintermute

+2

你錯過了另一個逗號:''c''d'' –

回答

1

初始值設定項列表中存在拼寫錯誤。你忘了放置逗號

char s[10] = {'a' , 'b' ,'c' 'd' ,'e', 'f', 'g', 'g','h','i'}; 
          ^^^^