-11 c++ syntax-error
目的:获得输出"(212)767-8900"
#include <iostream.h>
#include <conio.h>
using namespace std;
struct Phone
{
int area;
int exc;
int num;
};
void echoer(Phone);
int main()
{
Phone no1, no2;
no1.area = 212, no1.exc = 767, no1.num = 8900;
void echoer(Phone no)
{
cout << '(' << no.area << ') ' << no.exc << '-' << no.num;
}
echoer(no1);
getch();
}
Run Code Online (Sandbox Code Playgroud)
你根本无法在另一个函数中定义一个函数.你试图在echoer里面定义main.相反,它应该走出去.
您还应该知道它'用于字符文字并"用于字符串文字.由于其中') '包含多个字符,因此需要使用字符串文字.