Home > Back-end >  The difference between array pointer and pointer array
The difference between array pointer and pointer array

Time:03-07

The difference between array pointer and pointer array

CodePudding user response:

Array pointer is a pointer to an array, is essentially a pointer and pointer array elements to an array of Pointers, is essentially an array

CodePudding user response:

//char (* * x [3] ()) [5]. What type of variable is//x? 
//
/analysis/C statement, the key is to find out what this variable is a (function, Pointers, arrays),
//is the function that is left is his arguments and return values,
//is a pointer that rest is shows that he points to what,
//is the rest of the array is a member of the array is what type,
//parsing rules of C language statement:
//start from the left side of the first identifier, carried out in accordance with the priority, * said is.. Pointer to a const said read-only, volatile variable, array [] says, are () function,
//
//x and [3] is a size of 3 array, the array of each element as a pointer, the pointer to a class of function, this function has no parameters and return type of a pointer, the pointer to a char array size is 5
#include
#include
Char num [5].
Char (* x00 ()) [5] {
Return & amp; Num.
}
Int main () {
Char (* * x [3] ()) [5].//is an array, the size is 3
Char * (* x0) () () [5].//an array of elements, is a function pointer
Char (* x00 () ()) [5].//function prototype, the parameter is null, the return value is a pointer
X000 char (*) [5];//the return value

X0=x00;
X [0]=x0;
X [1]=x0;
X [2]=x0;
Printf (" typeid (x). The name () is % s \ n ", the typeid (x). The name ());
return 0;
}
//the typeid (x). The name () is char (* (__cdecl * *) (void)) [5]

CodePudding user response:

//c + + Operators 
//Operators specify an evaluation to be performed on one of the following:
//One operand (unary operator)
//Two operands (binary operator)
//Three operands (ternary operator)
//The C + + language includes all C operators and adds several new operators.
//Table 1.1 lists the operators available in Microsoft c + +.
//Operators follow a strict precedence which defines the evaluation order of
//expressions containing these operators. The operators associate with either the
//expression on their left or the expression on their right. This is called
//"associativity." Operators in the same group have equal precedence and are
//evaluated left to right in an expression unless explicitly forced by a pair of
//parentheses, ().
//Table 1.1 shows the precedence and associativity of c + + operators
//(from highest to lowest precedence).
//
//Table 1.1 c + + Operator Precedence and Associativity
//The highest precedence level is at The top of The table.
//+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
//| Operator | Name or a fancy | Associativity |
//+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
//| : : | Scope resolution | None |
//| : : | Global | None |
//| | [] Array subscript | Left to right |
//| | () Function call | Left to right |
//| | () Conversion | None |
//| | Member selection (object) | Left to right |
//| - & gt; | | Member selection (pointer) Left to right |
//| + + | Postfix increment | None |
//| -- - | Postfix decrement | None |
//| new | the Allocate object | None |
//| delete | Deallocate object | None |
//| delete [] | Deallocate object | None |
//| + + | Prefix increment | None |
//| -- - | the Prefix decrement | None |
//| | * Dereference | None |
//| & amp; | Address - | None |
//| | + Unary plus | None |
//| - | Arithmetic negation (unary) | None |
//|! | Logical NOT | None |
//| - | Bitwise complement | None |
//| sizeof | the Size of the object | None |
//| sizeof () | the Size of the type | None |
//| typeid () | type name | None |
//| | (type) type cast (conversion) | Right to left |
//| const_cast | Type cast (conversion) | None |
//| dynamic_cast | Type cast (conversion) | None |
//| reinterpret_cast | Type cast (conversion) | None |
//| static_cast | Type cast (conversion) | None |
//|. * | Apply pointer to a class member (objects) | Left to right |
//| - & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related