C C
Function prototype:
Eg. Int Func (in, float, long z); // long z Will Be Warned!
INT func () // no parameters rather than any parameter
Float func (...) / / variable parameter list, avoid (?)
return value:
1. Each function has a return value, empty return value is Void
2, Return's results depend on the return value:
consider:
INT func () {
Return 1;
}
// ----------------------------------
Char func () {
Return 1;
}
3, VOID can't use Return
INT func () {
Return 1;
}
// ----------------------------------
Char func () {
Return 1;
}
3, VOID can't use Return
Library:
How to use: Contains header files
//...slightly...//
note:
1. You can define the variable at any time;
2, Goto:
GOTO jumps out multiple cycles, high readability;
Of course, write the loop to the function and return Return, each layer is set;
Recurns: Write when writing algorithm notes
Operator priority: check list!
Self-increased self-reduction:
1, efficiency
I // No temporary variable
i // temporary variable
2, the order of operation
CONSIDER:
i = 1;
Y = i // y = 1, i = 2
Or y = I // y = 2, i = 2
Please refer to: http://community.9cbs.net/expert/topic/3688/3688400.xml? Temp = .260235
Data Type: Internal Type, Abstract Type (Customized Class)
Basic internal type: only specifies the storage critical value, binary and its conversion to digit; 6E-4
BOOL: Implicit Conversion? ?
Situ: Specifier
Long / short value upper limit Float 4 Double 8 long double 10
Modification int: long A is long int a
Signed / unsigned is using symbolic
It can be seen that Long Short cannot modify char, because char only one, and Signed Unsigned cannot modify floating point types because the floating point type always contains a symbol.
Pointer: I finally arrived! :)
* Who is more intimate?
Define a variable PTR to store the address, how to do it?
INT * PTR = & A
We actually want to be PTR = & A, but there is no basic internal type to read the data such as & A, so insert a * to indicate the pointer, then * and who is closer?
Consider two statements:
1, int * ptr // is closely related to the type
2, int * ptr // is closely related to variables
But they all have their own difficulties:
1, int A, b, c is feasible, according to this logic Int * A, B, C is also possible, but in fact, we have to write
INT * a;
INT * B;
INT * C; 2, INT * PTR = & a This is also like saying * ptr = & a, and this is not what we want
Eckel gives us a new answer: * is inserted, and there is no relative relationship before and after, just a logo tells the compiler: "Wait, it is a pointer."
Uses: Modify external objects; some programming skills
Modify external objects:
Why can you modify it? We can first look at what the definition and initialize a variable, which helps to understand the value pass and address delivery. To remember three nouns: Name (access ID), value, memory address. The value stores in the memory address, and the name is just accessing the address to obtain the value of the access ID, which can be considered to be more tight, one or one, and the access identity can have multiple, we look an example:
E.G: int a = 23; // First identification A and a unique value 23
Suppose & a = 4198736 // Unique address has been converted to a long type
INT * PTR = & a; // Second identification * PTR
Why is the second logo not PTR? Because the value of the PTR is the memory address, you can get access to the PTR * operation.
The second identification of 4198736 is equivalent to the first identification A. So from functional,
* PTR is the same as A // two access ID
PTR and & A // Here is some, PTR is actually a new name, it corresponds to another value
//, the memory address. After reading the following procedure:
Void main () {Int a; int * PTRA = & a; cout << (long) PTRA << Endl; cout << (long) & ptra << endl;}
Reference introduction
"(Quote) Basic idea and the use of the pointer described above: we can deliver parameter addresses with references. The reference and pointer difference is that the band-referenced function calls are called the syntax composed of the function of the pointer. Cleaner (in some case, using the reference is essentially only different) "
INT & A = B;
That is to establish an alias A, and the "said" waiting, it's a reference ", or use the name, value, address relationship, we can see this:
INT b = 1;
INT & A = B;
Name: B, A: 1 Address: & A or & B (& A = & B, this is the best evidence of the alias of A))
Use references to be clearer in grammar, more in line with human thinking.
For more details, please see:
http://dev.9cbs.net/develop/Article/62/62577.shtm C FAQ reading notes [2] - reference
Select Blog from Oury
http://dev.9cbs.net/develop/Article/57/57367.SHTM C basic work: starting from a left and right value, 侃 C reference
Select Blog from ShoOow
INT func () {
Return 1;
}
// ----------------------------------
Char func () {
Return 1;
}