This series of tutorials introduces you to c programming.

 

This is the first lecture of the tutorial, let’s first understand the C language program template, do everything to have a template, C language is no exception, so what is the C language template?

 

#include <stdio.h>

 

int main(){

_________ // Your code

 

            return 0;

}

 

The above is the C language program template, is not very simple? Compared to other templates, there is no immediate feeling that the C language template is really weak!

 

Learning a programming language usually starts with “Hello, World!” The function of this program is to print the string “Hello,world!” on the monitor. How is c implemented?

 

Do any thing to have a clear idea, C programming language is no exception.

 

Step 1: Write a TEMPLATE for THE C language.

#include <stdio.h>

 

int main(){

_________ // Your code

            return 0;

}

 

Step 2: Write the code that implements the functionality in the specified location.

 

#include <stdio.h>

 

int main(){

printf(“hello,world”); // Your code

            return 0;

}

 

Step 3: Compile the execution and view the results.

 

 

conclusion

When we write any C language program, we should follow the above program template, write code in the specified location, and finally compile and execute to see the program result.

 

For the helloWorld program above, we do the following:

1) The function of helloWorld program prints “Hello,world!” on the monitor. String, but we do not understand how the display works, how to achieve such a complex function?

 

Fortunately, we don’t have to do any of this work ourselves, because c’s pre-defined printf function does most of the work for me, and we just need to tell the printf function what to print. Printf is a system function defined by C language in advance. Its main function is to print information on the screen. So what is a function? What are the components of a function? Please pay attention to “C language tutorial functions”.

 

2) // Your code is called a comment, some code is difficult to understand, add some comments, can help us better understand the code. Please pay attention to “C language tutorial notes” for details.

 

3) #include<stdio.h> This line of code is called a header file, so why include this header file? For details, please refer to the C language Tutorial Header file.