Home > Back-end >  Small white would like to ask about the c language pointer array input problem
Small white would like to ask about the c language pointer array input problem

Time:10-01

In establishing a [10], an array pointer p point to write the scanf input statements, after a while & amp; A [I] between p++ and what's the difference? Thank you bosses guide a thank!!

CodePudding user response:

& A [I]==p + I
A [I]==* (p + I)

CodePudding user response:

No difference between
Do you want to ask is & amp; A [I] and p + I, the two equivalent
Is refers to the address of a [I] this element

CodePudding user response:

refer to the second floor yukint response:

no difference betweenDo you want to ask is & amp; A [I] and p + I, the two equivalent
Refers to a [I] this element address
book written for (a) the scanf (" % d ", p++); I want to ask who the p++ is completely equivalent to & amp; [I] is not what the difference between a

CodePudding user response:

Pointer is indirect addressing, as you have a room on a piece of paper to record the address (such as a few floor room), to find a piece of paper to see room address to take things in the room; Address-of operator is direct addressing, that is, do you know which floor room a few room, can go directly to the room to take things,

Don't obsess over the concept (except for the exam), see example, write procedures, naturally understand!

CodePudding user response:

P++ with & amp; [I] a equivalence condition is: array is stored in a row, a

Is equivalent to take what you want to go to 306307308, as long as find the sixth on the third floor of the room (306) can, in turn, to take things in the room (p++); While & amp; A equivalent said: [I] sixth on the third floor of the room, the room on the third floor the seventh, eighth room on the third floor...

CodePudding user response:

 # include 
#include

Typedef int elemtype;

Typedef struct lnode {
Elemtype data;
Struct lnode * next;
} lnode * linklist;

Void insert_sortlist (linklist & amp; L, elemtype e)
{
Linklist p, s;
S=(linklist) malloc (sizeof (lnode));
if (! S)
The exit (0);
S - & gt; data=https://bbs.csdn.net/topics/e;
P=L;
While (p - & gt; Next& & P - & gt; Next - & gt; The data & lt;=e)
P=p - & gt; next;
S - & gt; Next=p - & gt; next;
//s - & gt; Next=s;
P - & gt; Next=s;
}

Void create_sortlist (linklist & amp; L)
{
Elemtype e;
L=(linklist) malloc (sizeof (lnode));
L-> Next=NULL;
Printf (" build an ordered list, input shaping data ended with 0 \ n ");
The scanf (" % d ", & amp; E);
While (e)
{
Insert_sortlist (L, e);
The scanf (" % d ", & amp; E);
}
}

Void mergeincrease (linklist & amp; La, linklist & amp; Lb, linklist & amp; Lc)
{
Linklist p, q, s, rear;
P=La - & gt; next;
Q=Lb - & gt; next;
Lc=rear=La;
Free (Lb);
While (p& & Q)
{
If (p - & gt; Data{s=p;
P=p - & gt; next;
}
The else
{s=q;
Q=q - & gt; next;
}
Rear - & gt; Next=s;
Rear=rear - & gt; next;
}
If (p)
Rear - & gt; Next=p;
The else
Rear - & gt; Next=q;

}

Void visit_link (linklist phead)
{
Linklist p=phead - & gt; next;

While (p) {
Printf (" % d ", p - & gt; The data);
P=p - & gt; next;
}
Putchar (10);
}

/* void traverse by linklist (Lc)
{
Linklist p;
Printf (" combined list as follows: ");
For (p=Lc - & gt; next; P; P=p - & gt; Next)
Printf (" % d ", p - & gt; The data);
printf("\n");
} */

Int main ()
{
Linklist La, Lb, Lc;
Create_sortlist (La);
Visit_link (La);
Create_sortlist (Lb);
Visit_link (Lb);
Mergeincrease (La and Lb, Lc);
Linklist p;
Printf (" combined list as follows: ");
Visit_link (Lc);
/*
For (p=Lc - & gt; next; P; P=p - & gt; Next)
Printf (" % d ", p - & gt; The data);
*/

}

For your reference ~

CodePudding user response:

reference 6 building self-confidence boy reply:
 # include 
#include

Typedef int elemtype;

Typedef struct lnode {
Elemtype data;
Struct lnode * next;
} lnode * linklist;

Void insert_sortlist (linklist & amp; L, elemtype e)
{
Linklist p, s;
S=(linklist) malloc (sizeof (lnode));
if (! S)
The exit (0);
S - & gt; data=https://bbs.csdn.net/topics/e;
P=L;
While (p - & gt; Next& & P - & gt; Next - & gt; The data & lt;=e)
P=p - & gt; next;
S - & gt; Next=p - & gt; next;
//s - & gt; Next=s;
P - & gt; Next=s;
}

Void create_sortlist (linklist & amp; L)
{
Elemtype e;
L=(linklist) malloc (sizeof (lnode));
L-> Next=NULL;
Printf (" build an ordered list, input shaping data ended with 0 \ n ");
The scanf (" % d ", & amp; E);
While (e)
{
Insert_sortlist (L, e);
The scanf (" % d ", & amp; E);
}
}

Void mergeincrease (linklist & amp; La, linklist & amp; Lb, linklist & amp; Lc)
{
Linklist p, q, s, rear;
P=La - & gt; next;
Q=Lb - & gt; next;
Lc=rear=La;
Free (Lb);
While (p& & Q)
{
If (p - & gt; Data{s=p;
P=p - & gt; next;
}
The else
{s=q;
Q=q - & gt; next;
}
Rear - & gt; Next=s;
Rear=rear - & gt; next;
}
If (p)
Rear - & gt; Next=p;
The else
Rear - & gt; Next=q;

}

Void visit_link (linklist phead)
{
Linklist p=phead - & gt; next;

While (p) {
Printf (" % d ", p - & gt; The data);
P=p - & gt; next;
}
Putchar (10);
}

/* void traverse by linklist (Lc)
{
Linklist p;
Printf (" combined list as follows: ");
For (p=Lc - & gt; next; P; P=p - & gt; Next)
Printf (" % d ", p - & gt; The data);
printf("\n");
} */

Int main ()
{
Linklist La, Lb, Lc;
Create_sortlist (La);
Visit_link (La);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related