如何编写运行helloworld.cpp
一、新建cpp文件夹(用于存放cpp文件)
mkdir cpp
二、进入文件夹
cd cpp
三、新建helloworld.cpp
touch helloworld.cpp
四、编写代码
vim helloworld.cpp
代码如下:
#include <iostream>
int main()
{
std::cout <<"Hello World!\n"<< std::endl;
return 0;
}
五、测试与运行
执行下面的命令
g++ helloworld.cpp -o test
没有报错,执行输出结果命令
./test
正确输出结果
记得关注点赞哟!!!