0:打开C语言大门
作者:互联网
C语言教程
C语言教程开端
-
详见: 菜鸟教程
-
简单介绍:走个过场
-
C 语言是一种通用的、面向过程式的计算机程序设计语言。1972 年,为了移植与开发 UNIX 操作系统,丹尼斯·里奇在贝尔电话实验室设计开发了 C 语言。
C 语言是一种广泛使用的计算机语言,它与 Java 编程语言一样普及,二者在现代软件程序员之间都得到广泛使用。
当前最新的 C 语言标准为 C18 ,在它之前的 C 语言标准有 C17、C11...C99 等。
1—0 : 第一个程序讲解
// # include 包含 <stdio.h> .h head 有文件 stdio
// standard i input 输入 o out 输出
// 这个文件可能会包含一个标准输入输出的头文件
#include<stdio.h>
int main(void)
{
/* 注释:不被编译器识别 */
// 注释
printf("Hello World! \n");
// print 打印 f format 格式化
// printf 格式化输出
return 0;
}
输出结果 :Hello World!
解析:
- 所有的 C 语言程序都需要包含 main() 函数。 代码从 main() 函数开始执行。
- /* ... */ 用于注释说明。
- printf() 用于格式化输出到屏幕。printf() 函数在 "stdio.h" 头文件中声明。
- stdio.h 是一个头文件 (标准输入输出头文件) , #include 是一个预处理命令,用来引入头文件。 当编译器遇到 printf() 函数时,如果没有找到 stdio.h 头文件,会发生编译错误。
缺少 #include<stdio.h> 会报错:
报错展示:
demo.c: In function ‘main’:
demo.c:14:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
printf("Hello World! \n");
^~~~~~
demo.c:14:5: warning: incompatible implicit declaration of built-in function ‘printf’
demo.c:14:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
以上笔记内容来源于B站: Micro_Frank
标签:main,include,头文件,语言,declaration,C语言,printf,打开,大门 来源: https://www.cnblogs.com/NorthFot/p/c.html