Hi.
The function you described does indeed do that.
Here's a tester for it:
Code:
typedef struct node
{
char c;
int n;
struct node *next;
};
void flip(struct node *a, struct node *b);
int main()
{
node *p, *q;
node x, y;
x.n = 1;
y.n = 2;
p = &x;
q = &y;
printf("x = %i\ny = %i\n", x.n, y.n);
printf("p = %i\nq = %i\n", p->n, q->n);
getch();
flip(p, q);
printf("x = %i\ny = %i\n", x.n, y.n);
printf("p = %i\nq = %i\n", p->n, q->n);
getch();
return 0;
}
void flip(struct node *a, struct node *b)
{
struct node temp;
temp = *a;
*a = *b;
*b = temp;
}
<< end of code marker fixed by Salem >>
I hope that helps
This linked list stuff is something I really need to get a grip on too. I've been putting it off for the most part...