【发布时间】:2018-09-24 06:58:24
【问题描述】:
当我想输入年份后的地址时,编译器不会等待我的回答
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
cout << "What year was your house built?\n";
int year;
cin >> year;
cout << "What is its street address?\n";
char address[80];
cin.getline(address, 80);
cout << "Year built: " << year << endl;
cout << "Address: " << address << endl;
cout << "Done!\n";
return 0;
}
【问题讨论】:
-
请注明这是什么语言。
-
只需复制粘贴您的代码。它工作正常。你能详细说明错误吗?
-
请将所有 '\n' 替换为 endl 并检查。
-
它正在工作!使用 g++ Linux
-
你能再检查一遍吗?