The difference is: 1. *p represents the content stored in the memory address pointed by this pointer, p represents the name of a pointer variable; 2. *p is generally a variable or constant that is consistent with the pointer type, p The output is a hexadecimal number; 3. *p tells the program to retrieve data from that address, and p stores the address.
The operating environment of this tutorial: Windows 7 system, C 17 version, Dell G3 computer.
In C language, *p and p are commonly used in pointers to represent a pointer variable. The difference between *p and p is:
1. The meanings are different
* p represents the content stored in the memory address pointed to by this pointer.
p represents the name of a pointer variable, which refers to the memory address pointed to by the pointer variable.
2. The output format is different
*p is generally a variable or constant that is consistent with the pointer type.
p outputs a hexadecimal number and outputs the address of a pointer.
3. Different functions
*p Let the program go to that address to retrieve the data.
p stores the address.
Examples:
1,
int a[5]={1,2,3,4,5}; int *p=a;//这是在定义指针变量p的同时就直接给它初始化,即把数组a的首地址赋给它。
2,
int a[5]={1,2,3,4,5}; int *p;//声明指针变量p p = a;
Extended information
(*p) operation is an operation that returns the value of p as the value of the address space. (&p) is an operation that returns the address opened when p was declared. You can use assignment statements to assign values to memory addresses.
Example:
int *p; p=2003H; *p=3000H
Result:
**p=*(*(p))=*(*(2003H))=*(3000H)=3000H。 &&p=&(&(p))=&(3001H),此时出错了,3001H 是个常数无法存放地址。 *&p=*(&(p))=*(3001H)=2003H,也就是*&p=p。
Recommended tutorial: "C#"
The above is the detailed content of What is the difference between *p+1 and *(p+1). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor
