Article directory
1. Introductory case
Code:
#include<stdio.h>
int main(){
//打印一行文字
printf("你好,世界!\n");
return 0;
}
running result:
How does it work?
- Download VS ( https://visualstudio.microsoft.com/zh-hans/ )
- Baidu One Online Run ( https://www.bejson.com/runcode/c740/ )
- Using gcc under Linux
I am using gcc. Compile a c file:
gcc 文件名
A.out is generated by default, and the console calls:
./a.out
2, the main function
The function named main from which the program execution begins.
int main(){
return 0;
}
This code also works, although it does nothing.
3. Output a sentence
Import a library and call methods in it:
#include<stdio.h>
printf("你好,世界!\n");
To execute it at runtime, place the call in the main function:
#include<stdio.h>
int main(){
printf("你好,世界!\n");
return 0;
}
4. Notes
Comments do not affect the running of the code.
Write a thousand lines, and do not write, the effect is the same.
Single-line comments: from double slash to end of line.
A row.
//注释内容
//注释内容
Multi-line comments: from beginning to end.
You can write content in between.
/*
多行注释
多行注释
*/