[英]C++ , can't get it to run hello world code
First I was not able to install GWmin gcc.首先,我无法安装 GWmin gcc。 Now that I am done with that I have a new issue the build says there is nothing to build even when I have put a hello world programme in there.既然我已经完成了,我有一个新问题,构建说即使我在其中放置了一个 hello world 程序,也没有什么可构建的。
#include <iostream>
int main()
{
cout << "hello!! World\n"
}
return 0;
Another thing that I noticed it contrary to the video link I shared here my eclipse is not picking up a close bracket when I type in the opening bracket no color change of the word include after# pls help.我注意到的另一件事与我在此处分享的视频链接相反,当我在左括号中键入时,我的日食没有选择右括号,单词 include after# pls help 没有颜色变化。
First , try, (underneath #include) typing首先,尝试,(在#include 下)输入
using namespace std;
to even everything out, and I think you may want to change把一切都搞定,我想你可能想要改变
cout<<"Hello!! World \n"
to到
cout<<"Hello!! World \n"<< endl;
(last characters a lowercase L, in case your font type makes it look like a 1) (最后一个字符是小写 L,以防您的字体类型使它看起来像 1)
Second , make sure that you're using g++ , instead of gcc (Happens to me all the time)其次,确保您使用的是g++ ,而不是gcc (一直发生在我身上)
Lastly , if that doesn't work, move the return 0;最后,如果这不起作用,请移动return 0; into the brackets,放在括号里,
that should fix everything这应该解决一切问题
There are three mistakes in this small hello world program.这个小小的hello world程序有3个错误。
cout
. std 命名空间不提供cout
。 So change to std::cout
.所以改为std::cout
。cout
line.缺少分号( ; ), cout
行结束。return
statement should inside curly brackets {}. return
语句应该在大括号 {} 内。After making above changes your code进行上述更改后,您的代码
#include <iostream>
int main()
{
std::cout << "hello!! World\n";
return 0;
}
You are using \\n
for new line.您正在使用\\n
换行。 Since this is 'C++' code, It is recommended to use std::endl
for new line.由于这是“C++”代码,建议使用std::endl
作为新行。
If you working with Eclipse on Windows platform, try to install TDM-GCC MinGW Compiler.如果您在 Windows 平台上使用 Eclipse,请尝试安装 TDM-GCC MinGW 编译器。 It just a few clicks setup.只需点击几下即可设置。 Don't forget to choose MinGW compiler, when you create a new c++ project in Eclipse在Eclipse中新建c++项目时不要忘记选择MinGW编译器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.