Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 应为“”错误';之前_C++ - Fatal编程技术网

C++ 应为“”错误';之前

C++ 应为“”错误';之前,c++,C++,我似乎不明白为什么它总是说“期待”;“ 仅在第28行“保持窗口打开”之前,请帮助 #include<cmath> #include<vector> #include<algorithm> #include<iostream> #include<string> using namespace std; inline void keep_window_open(){char ch;cin>>ch;} int main()

我似乎不明白为什么它总是说“期待”;“ 仅在第28行“保持窗口打开”之前,请帮助

#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
inline void keep_window_open(){char ch;cin>>ch;}


int main()

{
cout<<"Please enter your first name(followed by 'enter'):\n";
string first_name;
cin>>first_name;
cout<<"hello,"<<first_name<<"!\n";
keep_window_open();
return 0;
cout<<"please enter last name:\n";
string Last_name;
cin>> Last_name;
cout<<"hello,"<<first_name<<Last_name<<"!\n"
// this is the only keep_window_open() function that gives me the problem 
keep_window_open();
return 0;  
} 
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
内联void保持窗口打开({char ch;cin>>ch;}
int main()
{
coutfirst_名称;

cout因为您忘记了前一行中的
(末尾没有
):

更改:

cout<<"hello,"<<first_name<<Last_name<<"!\n"

<代码> CUT> P> C++中,语句应该以<代码>结束;< /C> >/P>
cout<<"hello,"<<first_name<<Last_name<<"!\n"
cout<<"hello,"<<first_name<<Last_name<<"!\n";
以下是需要终止的声明列表

Statement type        Termination required?
==============        =====================
labelled statement              N (a)
expression                      Y
compound statements             N (a)
selection statements            N (a)
iteration statements            N (a) (b)
jump statements                 Y
declaration statement           Y
(a) 虽然有时可能会出现以分号结尾的情况,但事实并非如此。声明:

如果(i==1)doSomething(); 使用分号终止内部表达式语句,而不是复合语句,当您检查上面的第一个代码段(它位于{}大括号内)时,这一点应该很明显


(b) do需要在while表达式后加分号。

可以再次仔细阅读错误消息,并查看它试图告诉您的内容。如果错误表示某个内容前面应该有一个
,也许您可以检查它前面是否缺少
(即在前一个非空行上)在请求帮助之前;-)在第一次
保持窗口打开()之后返回0;
将在您进入“请输入姓氏”之前退出程序。
Statement type        Termination required?
==============        =====================
labelled statement              N (a)
expression                      Y
compound statements             N (a)
selection statements            N (a)
iteration statements            N (a) (b)
jump statements                 Y
declaration statement           Y