2011-05-19 65 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