Article catalogue
preface
1, What is C language?
C language is a language Process oriented of Abstraction General programming language, widely used in Bottom development . C language can be written in a simple way compile . low level processing storage . C language produces only a small amount of machine language And don't need any Operating environment Support an efficient programming language that can run. Although C language provides many low-level processing function , but it still remains Cross platform C language programs written in a standard specification can include similar features Embedded processor as well as Supercomputer And many other operating platforms Computer platform Proceed on compile.
2, The first C language program
Welcome to the world of programming, petite little princess (Prince)!
#include <stdio.h> int main() { printf("hello world\n"); return 0; } //The main function is the entry of the program //There is only one main function in a project
II. Data type
Mastering data types is a necessary way to learn C language.
char //Character data type short //Short int //plastic long //Long integer long long //Longer shaping float //Single-precision floating-point double //Double precision floating point number
#include <stdio.h> int main() { printf("%d\n", sizeof(char)); return 0; } //By analogy, you can try other data types //In programming software, sizeof (long) > = sizeof (int) //sizeof() is a memory capacity measurement function that returns the size of a variable or type (in bytes); In C language, sizeof() is an operator to judge the data type or expression length. You can try it on the computer.
char ch = 'w'; int long= 120; float width = 200f;
III. constants and variables
3.1 interpretation of terms
Some values in life are constant (such as pi, gender, ID number, blood type, etc.) - variables.
Some values are variable (e.g. age, weight, salary) - variables
3.1} classification of variables (local variables and all variables)
The following is a brief code introduction
#include <stdio.h> int A = 2019;//global variable int main() { int B = 2018;//local variable int A = 2020;//local variable printf("A = %d\n", A); return 0; } //There is no problem with the definition of local variable A above! //When local variables and global variables appear at the same time, local variables are used first
3.2 scope and life cycle of variables
Scope
life cycle
3.3 constants
#include <stdio.h> //give an example //Ale, female and secret in parentheses are enumeration constants enum Sex { MALE, // 0 FEMALE, // 1 SECRET // 2 }; //Note: enumeration constants start from 0 by default and increase by 1 in turn int main() { //Literal constant presentation 3.14159;//Literal constant 2000;//Literal constant //const modified constant const float Pai = 3.14f; //Pai here is a constant variable modified by const Pai = 6.33;//It cannot be modified directly! //#Demonstration of identifier constant of define #define MAX 100 printf("max = %d\n", MAX); //Enumeration constant demo printf("%d\n", MALE); printf("%d\n", FEMALE); printf("%d\n", SECRET); return 0; }
summary
Leave a message/comment before it becomes a top/hot tweet.