c language learning process【1】

Character and ASCII encoding

The standard ASCII encoding is introduced by the American National Standards Institute (ANSI). Characters in the C language follow the ASCII encoding method.
Insert image description here

Reference: link: link
• The ASCII code value of character AZ ranges from 65 to 90
• The ASCII code value of character az ranges from 97 to 122
• The difference in ASCII code value of the corresponding uppercase and lowercase characters (a and A) is 32
• The ASCII value of numeric characters 0-9 Code values ​​range from 48 to 57
• The ASCII value of line feed \n is: 10
• Among these characters, the ASCII code values ​​range from 0 to 31. These 32 characters are unprintable characters and cannot be printed and viewed on the screen.

string sum\0

String definition: A string of characters enclosed in double quotes is called a string.
A special knowledge in C language strings.There is a character hidden at the end of the string \0. This \0character is the end mark of the string..
Insert image description here
As can be seen from the picture below, arr1the length is 4, but arr2it is a random value. This is because when we use library functions printf() to print strings or strlen() calculate the length of strings, we \0 automatically stop when we encounter them.
Insert image description here

escape character

Escape characters are characters that change their original meaning.

escape character mean
\? Use it when writing multiple question marks in a row to prevent them from being parsed into three-letter words, which cannot be verified on new compilers.
\’ Used to represent character constants'
\" Used to represent double quotes inside a string
\\ Used to represent a backslash to prevent it from being interpreted as an escape sequence character.
\a Alert, which causes the terminal to sound an alarm, flash, or both.
\b Backspace key, the cursor moves back one character but does not delete the character.
\f Change the page character and move the cursor to the next page. On modern systems, this is no longer reflected, and the behavior is changed to something like \v.
\n Newline character.
\r Return character, move the cursor to the beginning of the same line.
\t Tab character, the cursor moves to the next horizontal tab stop, usually the next multiple of 8.
\v Vertical separator, moves the cursor to the next vertical tab stop, usually the same column on the next line.

The first two escape characters below can be understood as: the octal or hexadecimal representation of the character.

escape character mean
\ddd ddd represents 1~3 decimal numbers. For example: \130 represents the character X
\xdd dd represents 2 hexadecimal digits. For example: \x30 represents character 0
\0 The null character represents no content. \0 is a type of escape character such as \ddd. It is used as the end mark of a string. Its ASCII code value is 0.

Insert image description here
Why is there 7 here? \tIt's because the sum here \131only represents one character.

Classification of variables

Global variables:

Variables defined outside the curly braces are global variables. Global variables have a wider scope of use. If you want to use them in the entire project, there are ways to use them.

Local variables:

Variables defined inside curly braces are local variables. The scope of use of local variables is relatively limited and can only be used within the local scope where they are located.

At this time we have to consider a question, what if global variables and local variables are the same?
Insert image description here
It can be seen from thisLocal variables will be used first.
Insert image description here
What's more important to note is that these two num are completely different variables! ! !

Storage of local variables and global variables in memory:

Local variables are placed in the stack area of ​​​​memory.
Global variables are placed in the static area of ​​​​memory (for the time being, we can only introduce the superficial [doge])

++and--

Introduction: ++ is a self-increasing operator, which is divided into prefix ++ and postfix ++. - - is a self-decreasing operator, which is also divided into prefix - - and postfix - -.
Calculation method:
Prefix ++: Use ++ first, then use
Post++: Use first, then ++
(The same goes for pre- and post-)
Let’s demonstrate it with a code.

Insert image description here

-------------I will continue to share my programming learning journey in the future, so please give it a like and follow it----------

Guess you like

Origin blog.csdn.net/2301_77404033/article/details/131870979