2015-7-22, Wednesday
After one weeks of C language learning, the basic knowledge of grammar has been a certain understanding and understanding. At the same time through the three days of OC language Learning, more understanding of programming languages are mutually interlinked. Although the language of OC is different from the C,java of previous contact, it is easier to accept the instructor's interpretation and guidance.
The process of learning knowledge is not only the knowledge, but the simple understanding is not enough. In order to better develop in the future, we should understand and discriminate the learned knowledge, and realize it through code, deepen cognition.
Here is what I learned during this period of experience and summary.
One, the array of four methods of traversal:
There are two ways
1) pointer
·2) Array Cursors
The concrete realization is as follows, 21~24, total four kinds
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/F8/wKiom1Wu4qniZOKbAADtBRsvZR0727.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1wu4qnizokbaadtbrsvzr0727.jpg "/>
Second, the function pointer
Emphasizing the role of "pointers"
Iii. self-increment and use of pointer combination
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/F5/wKioL1Wu5I3hVVqjAADUvmmv_XY382.jpg "title=" 2.png " Style= "Float:none;" alt= "wkiol1wu5i3hvvqjaaduvmmv_xy382.jpg"/>
Print results
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/F8/wKiom1Wu4qqA2cZnAAA-AzMtSog246.jpg "title=" 3.png " Style= "Float:none;" alt= "wkiom1wu4qqa2cznaaa-azmtsog246.jpg"/>
"Focus" extension
1) Self-increment, decrement, and pointer combination use
·2) about the address of array a
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/F5/wKioL1Wu5I2hBuseAAFWfvL1eJg170.jpg "title=" 4.png " Style= "Float:none;" alt= "wkiol1wu5i2hbuseaafwfvl1ejg170.jpg"/>
Iv. Arrays and linked lists
Advantages and disadvantages of arrays:
• Advantages: Arrays are continuous and quick and easy to find.
• Cons: Insertion and deletion of arrays is cumbersome
List of advantages and disadvantages:
List each node stores two arrays, one is stored data, the other is the destination address of the next hop
• Advantages: Easy to insert and delete linked list
• Cons: Low traversal efficiency relative to array
V. About the array address +1
For example, &a + 1 corresponds to the address of A + (sizeof (a) * sizeof (int)) + (6 * 4)
That is, the length of space occupied by the address of a plus an array a
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/F5/wKioL1Wu5I6wFfG-AADVJhnD228478.jpg "title=" 5.png " Style= "Float:none;" alt= "wkiol1wu5i6wffg-aadvjhnd228478.jpg"/>
0. Structure, enumeration
One, scope-"{}"
That is {}
The scope of a name refers to the part of the program that can use that name
In short: declarations within {} are usually only used within {}.
(can also be used if it is declared in other places with extern)
Second, the characteristics and differences of various variables
1. Auto variable-"auto"
2. Static variable-"static"
A static variable that retains the last value.
The life cycle of static variables and the reference program bindings.
A static variable is written within a function or outside a function, and his life cycle is not limited by scope.
If the outside of the unload function, other functions can also use this variable. If it is written in a function, it can only be used in the corresponding function.
Storage Area: Static storage area.
3. Local Variables
4. Global variables
A global variable can be declared multiple times (with extern), representing the same variable, but cannot be defined more than once
5. Static global Variables
III. structure-"struct"
1. Concept
Defines a struct that simply illustrates the composition of the type and does not allocate storage space to it
The memory space occupied by the struct is the sum of the memory occupied by its members, and the members are sorted in memory in the order defined
2. Definition
1) Definition mode "3 kinds"
"Easy Error" • Defined type name, first letter must be capitalized
• struct {}; curly braces must end with ";"
2) nested definition, but cannot recursively call itself
3. Initialization and use
cannot be initialized in 42 rows (note the initialization of the distinguished array)
"." is an operator
Four, the structural body pointer
1. Because each struct variable has its own storage space and address, the pointer can point to the struct variable
2. The way the structure pointer is used "3 kinds"
The third way of "focus"-26 rows
printf ("Name is%s\n", p-, name);
V. Enumeration-"Enum"
1. Enumeration is used to define a series of types of
2. The enumeration value is actually a value, the enumeration value is starting from 0, and then sequentially accumulating on the basis of the previous value
3. Definition of "3 kinds"
3 ways to define a reference structure (similar)
VI. typedef
1. Use the TypeDef keyword to define a new name (alias) for various known data types
The first letter of "Easy error" must be capitalized
"Easy to Mistake"
1. The end of the definition structure must be added;
2. Struct, the enumeration letter must be uppercase
3. The difference between typedef and define
OC language
Ii. some differences between OC and C
1. import Header File
· C: Use #include <stdio.h> Import header file
· OC: Use #import <Foundation/Foundation.h> Import header file
which header file with C in Foundation
2. String
· in the Use%@ format in OC to print a string object
Iii. differences between classes and objects
Class is the type of object
Unlike basic types such as int, this type of class has a method
Iv. attribute declaration "3 kinds"
1) Public: Common, all classes can be used
2) Protected: Protected, defined class and its subclasses can be used
3) Private: Proprietary, can only be used in defined classes
V. Steps to define a class
1) define the class name
2) Write an instance variable of the property of the class
3) Methods of writing classes
------------------------------------------------------------------------------
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/F9/wKiom1Wu5QDjhT0fAAFkegUFedM168.jpg "style=" float: none; "title=" unlimited interconnect 01.png "alt=" Wkiom1wu5qdjht0faafkegufedm168.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/F5/wKioL1Wu5uTgxlshAAIDGIYvG4E889.jpg "style=" float: none; "title=" unlimited interconnect 02.jpg "alt=" Wkiol1wu5utgxlshaaidgiyvg4e889.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/F5/wKioL1Wu5uTA422GAABxXfkwOoA055.jpg "style=" float: none; "title=" unlimited interconnect 03.jpg "alt=" Wkiol1wu5uta422gaabxxfkwooa055.jpg "/>
C language and OC language Early learning experience