Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.31 KB

File metadata and controls

39 lines (27 loc) · 1.31 KB

C 程序:HelloWorld

原文: https://www.programiz.com/c-programming/examples/print-sentence

在此示例中,您将学习打印"Hello,World!"。 在 C 编程的屏幕上。

要理解此示例,您应该了解以下 C 编程主题:


显示 HelloWorld 的程序

#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
} 

输出

Hello, World! 

那么 HelloWorld 程序为何有效?

  • #include<stdio.h></stdio.h>是一个预处理器命令,它告诉编译器在程序中包含stdio.h(标准输入和输出)文件的内容。
  • stdio.h文件包含诸如scanf()printf()之类的函数,分别用于输入和显示输出。
  • 如果不编写#include <stdio.h>而使用printf()函数,则程序将无法编译。
  • C 程序的执行从main()函数开始。
  • printf()是一种库函数,用于将格式化的输出发送到屏幕。 在此程序中,printf()显示您好,世界! 屏幕上显示文本。
  • return 0;语句是程序的“退出状态”。 简单来说,程序以该语句结束。