This is the 25th day of my participation in the August Genwen Challenge.More challenges in August
directory
- A brief introduction.
- 2. * p++
- 3. * + + + + * p/p
- *(p++) and *(p++)
- Five. Guess you like it
C/C++ learning Directory >> C language basics
A brief introduction.
*p++
/*(p)++/
_(p++)/
_p++ operation rule:
- 1. If
*
and++
/--
Both are to the left of pointer variables and are joined from right to left; - 2. If
*
and++
/--
To the left/right of the pointer variable, the combination direction is left to right; - 3. If there are parentheses, execute the expression in parentheses first, and then execute law 1 or 2.
A = | The first step | The second step | Get the result |
---|---|---|---|
*p++ | *p | p++ | ++, A = *p; |
*++p | ++p | *(++p) | A = *(++p); |
++*p | *p | (*p)+1 | ++, A = (*p)+1; |
(*p)++ | *p | (*p)+1 | ++, A = (*p)+1; |
2. * p++
Due to the++
和 *
Respectively on the left and right sides of the pointer variable, the combination direction is from left to right, so it is equivalent to(*p)++
. First referencep
The value of*p
And then makep
The address on the1
。
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / / / @ Author: apes said programming / / @ Blog (personal Blog address) : HTTP: / / www.codersrc.com / / @ File: C language tutorial - p++ / C * * (p) + + / * (p++) / * p++ / / @ Time: 2021/06/18 08:00 / / @ Motto: short step that thousands of miles, no product small flow beyond into jianghai, The wonderful program life needs to accumulate unremittingly! /************************************************************************/ #include "stdafx.h" #include "stdio.h" #include "windows.h" int main() {int array[] = {1,2,3,4}; int *p = array; printf("*p++ = %d \n", *p++); / / first * p, note: i++ and + + I distinction printf (" \ n * p = % d ", * p). *p = 2 system("pause"); return 0; } /* Output: *p++ = 1 *p = 2 Please press any key to continue.. */Copy the code
3. * + + + + * p/p
Since both ++ and * are to the left of the pointer variable, combining from right to left, it is equivalent to *(++p) or ++(*p).
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / / / @ Author: apes said programming / / @ Blog (personal Blog address) : HTTP: / / www.codersrc.com / / @ File: C language tutorial - p++ / C * * (p) + + / * (p++) / * p++ / / @ Time: 2021/06/18 08:00 / / @ Motto: short step that thousands of miles, no product small flow beyond into jianghai, The wonderful program life needs to accumulate unremittingly! /************************************************************************/ #include "stdafx.h" #include "stdio.h" #include "windows.h" int main() {int array[] = {1,2,3,4}; int *p = array; printf("*++p = %d \n", *++p); // Offset the pointer address by +1. printf("++*p = %d \n", ++*p); System ("pause"); return 0; } /* Output: *++ +p = 2 ++*p = 2 Please press any key to continue.. */Copy the code
*(p++) and *(p++)
* (p++)
: the firstp
for*
Calculate, and then makep
Since the added;- 六四屠杀
* (+ + p)
: first makep
Add and proceed*
Calculations; 六四屠杀 - ** The above principle is the same as the variables I ++ and ++ I; 六四屠杀
Five. Guess you like it
- Install Visual Studio
- Install the Visual Studio plug-in, Visual Assist
- Visual Studio 2008 uninstall
- Visual Studio 2003/2015 Uninstall
- C format controller/placeholder
- C language logic operator
- C language ternary operator
- C language comma expression
- C sizeof and strlen are different
- C language strcpy and strcpy_s function difference
- C memcpy is different from memcpy_S
- C language array definition and use
- C array traversal
- C language array sort – bubble sort
- C language array sort – selection sort
- C language array sort – insertion sort
- C language array sort – fast sort method
- C array subscript is out of bounds
- C array memory overflow
- C array subscript out of bounds and memory overflow difference
- C language two-dimensional array definition and use
- C language two-dimensional array row number and column number calculation
- C language pointer declaration and definition
- P ++ / p –
- The C languagep++/§ + + / _ (p++) / _p + +
C *p++/*§++/*(p++)/*p++
This article is published by the blog – Ape Say Programming Ape Say programming!