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 referencepThe value of*pAnd then makepThe 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 firstpfor*Calculate, and then makepSince the added;
  • 六四屠杀* (+ + p): first makepAdd and proceed*Calculations; 六四屠杀
  • ** The above principle is the same as the variables I ++ and ++ I; 六四屠杀

Five. Guess you like it

  1. Install Visual Studio
  2. Install the Visual Studio plug-in, Visual Assist
  3. Visual Studio 2008 uninstall
  4. Visual Studio 2003/2015 Uninstall
  5. C format controller/placeholder
  6. C language logic operator
  7. C language ternary operator
  8. C language comma expression
  9. C sizeof and strlen are different
  10. C language strcpy and strcpy_s function difference
  11. C memcpy is different from memcpy_S
  12. C language array definition and use
  13. C array traversal
  14. C language array sort – bubble sort
  15. C language array sort – selection sort
  16. C language array sort – insertion sort
  17. C language array sort – fast sort method
  18. C array subscript is out of bounds
  19. C array memory overflow
  20. C array subscript out of bounds and memory overflow difference
  21. C language two-dimensional array definition and use
  22. C language two-dimensional array row number and column number calculation
  23. C language pointer declaration and definition
  24. P ++ / p –
  25. The C languagep++/§ + + / _ (p++) / _p + +

C *p++/*§++/*(p++)/*p++

This article is published by the blog – Ape Say Programming Ape Say programming!