Pointers and linked list structure understanding
#include <stdio.h>
int main (void)
{
int a=3,*p;
p=&a;
printf ("a=%d,*p=%d\n", a,*p);
*p=10;
printf ("a=%d,*p=%d\n", a,*p);
printf ("Enter A:");
scanf ("%d", &a);
printf ("a=%d,*p=%d\n", a,*p);
return 0;
Analytical:
1. Define shaping variables A and shaping pointer p:int a=3,*p;
2. Assign the address of variable A to the pointer P, which is p pointing to a:p=&a;
3. The value of the output variable A and the value of the pointer p point to the variable: printf ("a=%d,*p=%d\n", a,*p);
4. Assign a value to the variable that the pointer p points to, which is equivalent to assigning a value to the variable a: *p=10;
5. The value of the output variable A and the value of the pointer p point to the variable: printf ("a=%d,*p=%d\n", a,*p);
6. Enter a:printf ("Enter a:");
scanf ("%d", &a);
Pointer variables are used to store addresses, whereas general variables store values. A pointer variable occupies four bytes. The format is the type name * pointer variable name.
The fetch address operator is &. Gets the address value from it.
* is an indirect access operator.
The dynamic linked list structure does not require a continuous storage space, and the nodes of the linked list are connected by pointers. In contrast to the array structure, there is no need to move a large number of elements when the linked list is inserted or deleted, just modify the corresponding pointer. Therefore, the list structure is particularly suitable for a large number of inserted or deleted programs.
The list structure contains two items: The 1,data variable, the struct type variable, and the data part of the linked list structure.
2, the pointer part, the pointer name is *next, through which it can point to the next node. *link is also a small pointer.
In a program where you need to use a linked list, you can write a node type directly.
ITCSC 15-2 class 150809227
Pointers and linked list structure understanding