31 days of C language - 1, introductory case

1. Introductory case

Code:

#include<stdio.h>
int main(){
    
    
	//打印一行文字
	printf("你好,世界!\n");
	return 0;
}

running result:

insert image description here

How does it work?

  1. Download VS ( https://visualstudio.microsoft.com/zh-hans/ )
  2. Baidu One Online Run ( https://www.bejson.com/runcode/c740/ )
  3. 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.

insert image description here

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.

/*
	多行注释
	多行注释
*/

Guess you like

Origin blog.csdn.net/qq_37284843/article/details/124381485