c language cyclic structure [] [] [Function] [Array] the pointer

1.while cycle
format:
the while (expression)
{
statement block;

}
order: Analyzing Expression 1 is satisfied, the establishment of circulating executed, if the establishment of a block of statements executed; otherwise, execution Expression 3

2
do ..while
format:
do

block of statements;
}
the while (expression);
execution order: a first iteration of the loop, the expression is determined again.


[] Array
1 does not initialize arrays have time, when using not the overall assignment below, only eleven assignment
example:
ST [. 5];
ST = {1,2,3,4,5};
above is wrong


1 Note: The name of the array represents the first address of the array is the address constant

Error:
ST [. 5];
ST ++;
error: error: lvalue required as left operand of assignment, to see the literal meaning: left operand of an assignment operator must use the Left value.
ST = ST +. 1 //;
// the name of the one-dimensional array is a constant address can not be assigned sum.


[1] 1.while cycle:
Format:
the while (expression)
{
block of statements;
}
order of execution: determining expression is satisfied, the establishment of the execution cycle, the cycle ends or

while (1); infinite loop
for (;;);

2.do ... while loop:
Format:
do
{
statement block;
} the while (expression);
execution order: first iteration of the loop, then determining the expression

[2] loop control statements:
1.break: the end of the cycle, only one end of the loop out of the loop body.
2.continue: the end of this cycle, the next cycle continued
use of: loop, break can also be used in a switch

Array [3]:
structure data types: a collection of one or more data types of substantially
1. Definition: An array is a collection of a certain sequence relationship between a number of variables, each variable consisting of an array element of the array is referred to.
2. Features:
the same data type
contiguous memory

[4] a one-dimensional array:
1. Define: only one array subscript
2. Format:
storage type data type array name [index];
int ST [. 5];
index from 0 to n-1 the end of the ST [ 0] -st [4]

3. Initialization:
1) all initialized, the array subscripts may be omitted
2) part of the initialization, the initial value uninitialized part 0
3) is not initialized, the initial value of a random value only a single element assignment

Note:
The first address of the array representatives of the array is the address of constant
size calculation array: sizeof (array name)

4 through the array: for loop
5. Clear:
void * Memset (void * S, C int, n-size_t);
Function: clearing operation
parameters: s: Address
C: 0
n-: n-byte size
Return value : S
void bzero (void * S, n-size_t);
function: clear
parameters: s: address
n: n bytes size
return value: None

 

[5] a two-dimensional array:
1. Definitions: Only two arrays subscript
2. Format:
storage type data type array name [row number] [column number];
int A [n-] [m];
the subscript a [0 ] [0] - a [n -1] [m-1]

3. Initialization:
1) all initialized: A [] [m]
2) part of the initialization, the initial value uninitialized part 0
3) is not initialized, only a single element assignment, not reference in its entirety

Note:
1. The line number can be omitted, the column number can not be omitted
2. The array name can not represent an array of the first address, on behalf of the row address.
3. & array name representative of the first address of the array
4 through the array: for nested loop
[6] array of characters:
char ST [32] = { 'A', 'B', 'C'};
= "Hello" ; // the sizeof (ST) = 32
char buf [] = "Hello"; // the sizeof (buf) =. 6

[2] dimensional array
int a [] [3] = {1,2,3,4,5, 6}
// row number, column number
// row number may be omitted, the column number can not be omitted.
// array name is a row of double-digit group addresses the first line. (Very important)
[3] character array
ST [3] = { 'A', 'B', 'C'};
ST [] = { "ABC"};
[4] the pointer
1.
'*': 1) defined pointer variable
2) Previous address *: content fetch address
3) downgrade row address column address (very important)
2.
. 1) int * P = NULL; (prevent stray pointers).
2) conversion of pointer type: for example: A = int 10;
void * P;
P = & A;
the printf ( "% P",

Pointer Array [5]
1. Definition: essentially pointer to array specific number of bits
2 format: Data types (array pointer variable * name) [index]; ==> int (* p ) [4];
e.g. : a int [] [. 3] = {1,2,3,4,5,6};
int (* P) [. 3] = ST; // pointer to an array name, then the equivalent ==> p ++ is equivalent to the array mobile line;
the printf ( "% D", * (P *), * (* (P +. 1))); a first element of a first element // print line, and print the second line.

3. The two-dimensional array can not point to a simple pointer
4. pointer variable is always only four bytes.

 

Guess you like

Origin www.cnblogs.com/hehu/p/11565014.html