Arithmetic operation and relation operation of C + + pointer

Time:2022-5-6

The following essay is about the arithmetic operation and relational operation of the pointer.

Arithmetic operation of pointer type

  • Addition and subtraction of pointer and integer

  • Pointer + +, – operation

Arithmetic operation of pointer type

  • Pointer P Plus or minus n

    • Its meaning is that the pointer points to the starting position of the nth data in front or behind the current position.

  • + +, — operation of pointer

    • Meaning refers to the beginning of the next or previous complete data.

  • The result value of the operation depends on the data type pointed to by the pointer and always points to the starting position of a complete data.

  • When the pointer points to the same type of data stored continuously, the addition and subtraction of pointer and integer and the calculation of self increase and self decrease are meaningful.

The meaning of adding pointer and integer

Relational operation of pointer type

  • Various relational operations can be performed between pointers pointing to the same type of data.

  • Pointers to different data types and the relationship between pointers and general integer variables are meaningless.

  • The pointer can perform an equal or unequal relationship operation with zero.

For example: P = = 0 or P= 0

Recommended Today

Usage Summary of Python collaborative process (I)

1、 Python collaboration keyword Async: declare collaboration Note: the function declared through async is not a function, and a separate call will not be executed Await: it is used to wait for objects that can wait, including collaboration (that is, the collaboration declared by async), task (asyncio. Create_task(), asyncio ensure_ Future () is the task […]