Hello everyone! I learned two chapters on python two days ago. I feel that python is great! (Although I don't know where it is !) Hey! Later, I had no intention of seeing that C language is a language that can operate hardware (and I don't quite understand what it means !). It seems that many people have positioned him in the intermediate language! Then I had an idea. If I want to learn C and python together, I may think that it is just for fun and there is no pressure to study. So I am so "bold. Do not think that I am like the monkey in a small book !" Haha! I. The first C program and its preliminary explanation
Why C language ?! I used to think the computer is so strange! How does she represent everything in the world! By searching for the network, I understand that different codes make different meanings! Oh! What exactly does the computer know! I heard that the computer brain only knows binary data. This "pig's head" is a good thing. It's a fast computation! Otherwise it would be too stupid! I heard that the first program in the world is female ~! Then she should have written the program in binary! Amazing! Some days ago, I had a lot of video tutorials on the donkey! As long as I downloaded all the computers, I saw many people talking about OD! There are a lot of things in it! Don't understand! However! Later, I learned about 1-point hexadecimal conversion and understood it. It turns out! Binary writing is long and it is easy to write errors! Therefore, binary is often expressed in hexadecimal notation (whether the ADA is a binary program or a hexadecimal program ). Later, we thought it was quite troublesome to write a program like this! Later I used the assembly language! The Assembly Language is like a nickname for a person, which is easier to remember! Therefore, the Assembly Language and binary code are one-to-one! But later! People think assembly languages are too cumbersome! It would be nice to write a program just like talking! Then I got the C language! C language is closer to natural language! But how can computers understand the C language! So we have the compiler, gcc, cl, and so on. The compiler first converts the C language into an assembly language! Then convert it to binary. In this way, the computer will understand it!
The first C program! Haha! It's time to start writing C Programs! I just typed one in VC according to the book.
#include<stdio.h>
int main(void)
{ printf("Hello World!"); return (0);
}
Dizzy! A lot of things not found in python! I have to read the book carefully to fully understand it!
The first line!Many people have their own toolkit for doing things! For example, uncle of circuit repair! Usually there is an electrical package! A carpenter also has a toolkit containing some common tools. Hey! Now I want to output helloworld on the screen! At this time, I need an output package! So # include <stdio. h> indicates to use the stdio. h package, and <> indicates where to get it. # Include indicates that the insert package starts here. Hey! I understand! In stdio. h, we can define how to output the output! In fact, this stdio. h contains not only output tools, but also input tools! So the code here is actually to get all the stdio. h toolkit! (It looks a waste! Alas !).
Line 2!Int main (void). In this line, we need to describe it first! A very special word is followed by (). In fact, this form represents a function in the C language, and the previous int Is the return value of the function! In fact, a function is like a living tool in a toolkit! You feed it something, for example, feed void, and let it spit out one int type thing! Hey! This alive tool can be used repeatedly! But this is a bit special! The tool named "main" is generally used only once, because it has a special mission !!! It is a user's entry function! In fact, the real entry function in VC is mainCRTStartup (). It has actually done a lot of work before the main () function of the user is in the middle of mainCRTStartup! For example, you have prepared a command line, obtained the operating system version, the initialization of IO, and obtained the environment options, as well as the initialization of its strings, global variables, and Conditional compilation! If it is a Win program, the entry is WinMain (). If it is not an entry, it is main! Then exit after main () runs the program! In fact, the main () function is the second to the last! However, generally, the main () function is used when programmers have operation permissions!
Row 3 and row 6! Ah!Why should we learn these two lines together! Because these two rows have only two parentheses! Haha! In C language, one pair of parentheses represents one code block! Just like the indentation of python! (This should be the case! I may have new insights when I learn more in the future! Now, let's take a look !)
Row 4!In fact, this line is to extract printf from stdio. h to output this tool (function), and then use this tool to print helloworld on the screen! String! Oh! Amazing! This is a good tool!
The fifth line!This is what happened when you first asked the main () function to spit out something after work, so that the system can know that the main () function is a bad thing! Here the return value is 0, which means that main () is actually doing things! Ah! I found a problem! The printf in row 4 Should Have Been spit out after work. Alas! I don't know how it works! Write it down first and learn what should be solved later!