03 以Hello World为例,分析C语言的最小的程序结构

时间:2020-07-07 09:37:57   收藏:0   阅读:68

C程序主要包含的部分

C Hello World 实例

如下程序,可以在屏幕输出短句"Hello World"

#include <stdio.h>
int main()
{
   /* 我的第一个 C语言程序 */
   printf("Hello, World! \n");
   
   return 0;
}

分析上面这段程序:

1、第1行 #include <stdio.h> 是预处理器指令,告诉 C 编译器在实际编译之前要包含 stdio.h 文件。
2、第2行 int main() 是主函数,程序从这里开始执行。
3、第3行 /.../ 将会被编译器忽略, /.../ 当中放置程序的注释内容。注释内容被称为程序的注释。
4、第4行 printf(...) 是 C 中另一个可用的函数,会在屏幕上显示消息 "Hello, World!"。
5、最后一行 return 0; 终止 main() 函数,并返回值 0。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!