From: 邢家朋 <47733616+xingjiapeng@users.noreply.github.com> Date: Sun, 6 Oct 2019 08:56:56 +0000 (+0800) Subject: Update helloworld.md X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c4da045548bbe3028f483006594dd6c7b877ad43;p=oi-wiki%2Fmain.git Update helloworld.md --- diff --git a/docs/lang/helloworld.md b/docs/lang/helloworld.md index c9837a33..0beba5d6 100644 --- a/docs/lang/helloworld.md +++ b/docs/lang/helloworld.md @@ -22,7 +22,7 @@ IDE 操作较为简单,一般入门玩家会选用 IDE 来编写代码。在 xcode-select --install ``` -#### NOI Linux +#### Linux 使用 `g++ -v` 来检查是否安装过 `g++` 。 @@ -34,10 +34,14 @@ sudo apt update && sudo apt install g++ 熟练之后也有玩家会使用更灵活的命令行来编译代码,这样就不依赖 IDE 了,而是使用自己熟悉的文本编辑器编写代码。 +g++是C++语言的编译器,C语言的编译器为gcc。 + ## 第一行代码 通过这样一个示例程序来展开 C++ 入门之旅吧~ +C++语言 + ```c++ #include // 引用头文件 @@ -46,3 +50,25 @@ int main() { // 定义 main 函数 return 0; // 返回 0,结束 main 函数 } ``` + +```c++ +#include // 引用头文件 + +using namespace std; + +int main() { // 定义 main 函数 + cout << "Hello, world!" // 输出 Hello, world! + return 0; // 返回 0,结束 main 函数 +} +``` + +C语言 + +```c +#include // 引用头文件 + +int main() { // 定义 main 函数 + printf("Hello, world!"); // 输出 Hello, world! + return 0; // 返回 0,结束 main 函数 +} +```