freeCodeCamp/guide/chinese/c/hello-world/index.md

1.0 KiB
Raw Blame History

title localeTitle
Hello World C Hello World C

你好,世界

要在控制台上编写,您可以使用库中include <stdio.h>的函数printf() include <stdio.h>

```C #包括

int mainvoid {

 printf("hello, world\n");  //lines starting with this are called comments.. 
 
 return 0; 

} ``` ##解释

  • #include 是一个预处理器命令。该命令告诉编译器在程序中包含stdio.h标准输入和输出文件的内容。

  • stdio.h文件包含scanf和print等函数分别用于输入和显示输出。

  • 如果使用printf函数而不编写#include ,该程序将不会编译。

  • C程序的执行从main函数开始。

  • printf是一个库函数用于将格式化输出发送到屏幕。在这个程序中printf显示HelloWorld屏幕上的文字。

  • 返回0; statement是程序的“退出状态”。简单来说程序以此声明结束

    输出:

    ```

你好,世界 ```