无法在 C++ 中使用 cout 函数
我是 C++ 新手,我无法运行我的第一个 C++ 程序,代码是
#include <iostream.h>
void main()
{
cout>>"Hello world!">>endl;
}
但未能在控制台上打印 "Hello world!"
,我对这个问题感到困惑小时,配置似乎没有错误,我使用的是 Visual C++ 2010 Express,它是基本控制台项目格式,有人可以帮助我吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的方向错了。
将
<<
视为将数据推入cout
(即输出)。相反,您可以使用
>>
和cin
将数据从输入推送到变量中。You have your direction wrong.
Think of
<<
as pushing data intocout
, i.e. the output.Inversely, you use
>>
withcin
to push data into a variable, from input.您应该启用编译器上的所有警告和调试信息。
“双箭头”应该指向流,因为它是输出,所以你可能应该说
You should enable all warnings and debugging information on your compiler.
The "double arrow" should go to the stream since it is an output, so you should probably say
1.
#include
已过时。Thinking in C++ 说它相当于
但后者是流行的。
2.
正如其他人所说,你应该使用
cout<<“世界你好!”<
3.
使用
;
而不是;
为了清楚起见,我猜 2 是你的主要问题,3 可能是一个拼写错误,而 1 是一个建议
1.
#include <iostream.h>
is outdated.thinking in C++ says it is equivalent to
But the latter is the prevailing one.
2.
as stated by others, you should use
cout<<"Hello world!"<<endl
3.
use
;
instead of;
To be clear, I guess 2 is your major problem and 3 maybe a typo while 1 is an advice