Home > Back-end >  C language structure
C language structure

Time:03-09

P - & gt; Str++ + + add in where?
I want to ask why not choose A? STR is a pointer to a pointer + 1 right? Where is the wrong grammar? Thank you for your reply, thank you very much! For the following structure definition, p - & gt; Str++ + + in _D____. J struct {int len. Char * STR; }, * p; A. pointer on STR b. c.s. tr, pointing to the pointer p content d. grammatical errors

CodePudding user response:

The answer is wrong. I was to choose A,

CodePudding user response:

Add in STR is no problem, p - & gt; Str++ is indeed STR + 1, points to the backward shift of a byte space, but p is wild pointer, wild pointer manipulation STR is undefined, but the compiler will not check here,
The subject matter has a certain feeling, strong grammatical errors are still a little far-fetched, but wild pointer problem does in the former,

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; * | Dereference pointer to a class member | Left to right |
//| | * Multiplication | Left to right |
//| | Division | Left to right |
//| | % the Remainder (modulus) | Left to right |
//| | + Addition | Left to right |
//| - | Subtraction | Left to right |
//| & lt; <| | Left shift | Left to right
//| & gt;> | | Right shift | Left to Right
//| & lt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related