1. Structures and unions
Table of contents
1.1 What are the characteristics of structures and unions?
1.2 Structure Alignment Principles
2.3.2 Configure personal information
2.3.3 Chinese display (independent of the execution path)
2.3.4 View personal configuration information
2.3.6 Submit the content of the workspace to the repository
2.3.8 View the status of the workspace
2.3.9 Losing the content of the workspace
1.1 What are the characteristics of structures and unions?
1.1.1 Structure
1) Data can be stored in batches
2) Can store different types of data
3) Support structure nesting
1.1.2 Community
1) The purpose of using the union variable is to store several different types of data in the same memory segment, but only one of them can be stored at each moment, instead of storing several at the same time; 2) What can be accessed is the
union The last assigned member in the variable, the original member will lose its effect after assigning a new member.
3) The address of the union variable and the addresses of its members are the same address;
4) You cannot assign a value to the union variable name; you cannot attempt to reference the variable name to obtain a value; you cannot initialize the union variable when defining it; You cannot use a union variable name as a function parameter.
1.2 Structure Alignment Principles
1) The first address of the structure variable can be divisible by the size of its widest basic type member;
2) The offset (offset) of each member of the structure relative to the first address of the structure is an integer multiple of the size of the member. If necessary, the compiler will add padding bytes (internal adding) between the members;
3) The total size of the structure is an integer multiple of the size of the widest basic type member of the structure. If necessary, the compiler will add padding bytes {trailing padding} after the last member.
2.Git
Git is currently the most advanced distributed version control system in the world. Each client has a complete version backup, and all version submissions do not need to rely on the central server. Only when multiple people collaborate, the server needs to exchange the version library.
2.1 Git role
1) Version control
2) Multi-person collaboration
2.2Git operation
1) Workspace: equivalent to the working folder
2) Repository: the location of Git backup
3) Remote warehouse: remote server
2.3 Git commands
Note: <> in all commands in the text represents mandatory parameters, [ ] represents optional parameters, and the content in <> is the explanation of the parameters, which need to be replaced when entering the command, for example, git add <file name> represents the command after git add Followed by a file name, such as git add test.txt.
2.3.1 General operations
In a folder that has not yet become a git repository, the right-click menu opens the "Git Bash Here" terminal.
ctrl+C: stop the input or execution of the current command
ctrl+L: clear screen
2.3.2 Configure personal information
git config --global user.name "name"
git config --global user.email "[email protected]"
2.3.3 Chinese display (independent of the execution path)
git config --global core.quotepath false
2.3.4 View personal configuration information
git config -l
2.3.5 Initialize warehouse
git init
2.3.6 Submit the content of the workspace to the repository
git add <filename>: * stands for all files --- git add *
git commit -m "<submitted content>"
2.3.7 View version records
git log
2.3.8 View the status of the workspace
git status
2.3.9 Losing the content of the workspace
git checkout <filename>
2.3.10 version rollback
git log
git reset --hard <version ID>
2.3.11 version forward
git reflog: Display reference records, which include all commit information
git reset --hard <version ID>
3.json
JSON is an acronym for JavaScript Object Notation, which is a data interchange format.
3.1 JSON data type
1) number: exactly the same as JavaScript's number; equivalent to the int type in C
2) boolean: it is the true or false of JavaScript; it is equivalent to the bool type in c++
3) string: it is the string of JavaScript; it is equivalent to the string type of C++
4) Null: JavaScript's null; equivalent to C's NULL type
5) array: It is the Array representation of JavaScript - []; equivalent to the array of C
6) object: It is the { ... } representation of JavaScript. Equivalent to a C++ class or a C structure
3.2 Basic format
1) The data type of json is related to the specific programming language in the source code implementation. For example, boolean has no corresponding type in C, and the C-related implementation library may be represented by 0 and 1;
2) json starts and ends with braces;
3) The content exists in the form of key-value pairs;
3) All keys are strings;
4) The type of the value is not necessarily, it belongs to the basic data type of JavaScript;
5) Each key-value pair is ,
split;
6) The last key-value pair does not include a comma.
Example:
{
"name": "小明",
"age": 14,
"gender": true,
"height": 1.65,
"grade": null,
"middle-school": "\"W3C\" Middle School",
"skills": [
"JavaScript",
"Java",
"Python",
"Lisp"
]
}
3.3 Basic operation of json
1) Json serialization: It can be understood as the process of using programs to generate Json strings.
2) Json deserialization: It can be understood as the process of using the program to parse the existing Json string into the value we need.
3.4 JSON mind map