2011-05-19 103 views
-5
void main (void) 
{ 
    char name [2] [30], number [2] [10]; 
    char << "Please type your first name, a blank, and last name) << endl; 
    cin >> name; 
    cout << "Name=" <<name << endl; 
    cout << "Please type a number, press the return key, and another number << endl; 
    cin >> number [0] >> endl; 
    cout << number << endl; 
} 
+3

我發現了錯誤:'無效的主要(無效)' – 2011-05-19 13:50:53

+2

這是新定義的經典範例「過於本土化」:這個問題不可能永遠幫助未來的訪問者;它只與一個小的地理區域,一個特定的時刻或一個非常狹窄的情況有關,而這種情況通常不適用於全球互聯網用戶。 – paxdiablo 2011-05-19 13:53:43

+0

還有人還在乎回答他們? :-) – 2011-05-19 14:03:03

回答

5

太多提及,但我們不是在這裏充當家庭作業服務。檢查你的編譯器的輸出,那麼解決這些問題一次一個:


qq.cpp:4:13: warning: missing terminating " character 
qq.cpp:4: error: missing terminating " character 
qq.cpp:7:13: warning: missing terminating " character 
qq.cpp:7: error: missing terminating " character 
qq.cpp:1: error: ‘::main’ must return ‘int’ 
qq.cpp: In function ‘int main()’: 
qq.cpp:4: error: expected unqualified-id before ‘<<’ token 
qq.cpp:6: error: ‘cout’ was not declared in this scope 
qq.cpp:6: error: ‘endl’ was not declared in this scope 
qq.cpp:8: error: ‘cin’ was not declared in this scope 

在最低限度:

  • 沒有using條款或std::前綴。
  • char不是流。
  • 對某些字符串文字沒有關閉引號。
1

有在"Please type your first name, a blank, and last name)

+0

也許有太多的事情要抱怨。 – Phonon 2011-05-19 13:51:48

1

末括號,而不是一個雙引號你不結束與「在

char << "Please type your first name, a blank, and last name) << endl; 

cout << "Please type a number, press the return key, and another number << endl; 
字符串

它應該是:

int main (void) 
{ 
char name [2] [30], number [2] [10]; 
char << "Please type your first name, a blank, and last name)" << endl; 
cin >> name; 
cout << "Name=" <<name << endl; 
cout << "Please type a number, press the return key, and another number" << endl; 
cin >> number [0] >> endl; 
cout << number << endl; 
return 0; 
} 
1
char << "Please type your first name, a blank, and last name) << endl; 

cout << "Please type a number, press the return key, and another number << endl; 

都缺少結束雙引號

char << "Please type your first name, a blank, and last name)" << endl; 
cout << "Please type a number, press the return key, and another number" << endl 
+0

第一個可能有_else_錯誤:-)提示,'char'是一個關鍵字。 – paxdiablo 2011-05-19 13:55:48