【发布时间】:2021-09-26 04:28:41
【问题描述】:
基础知识:使用 Visual Studio Code 的 C++,错误消息在终端中,“问题”或“输出”部分中没有任何内容。
#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Enter your age: ";
cin >> number;
cout << "Your age is: " << number;
return 0;
}
Basics: Visual Studio Code, C++
When I ran the above code it responded with the following in the terminal: "Enter your age: 22 Your age is: 22%"
Does this mean the user would only see 22 or would they see 22%?
【问题讨论】:
-
错误信息很明确:“use of undeclared identifier 'cout'; 你是说'std::cout'吗?”
-
您发布的代码不是编译器抱怨的代码。
std:cout << "Hello world!";没有出现在此代码中任何地方。无论如何,我在我的 vscode 中使用了完整的 clang 命令行工具的 xcode-select 安装,并且从未遇到过这个问题。 -
问题是缺少换行符,而你的 shell(可能是 zsh)告诉你很多。
标签: c++