#include <iostream>
using namespace std;
typedef struct Template
{
int a;
Template * link; // goes forward (one way reference)
} list;
typedef list * listptr;
int main()
{
listptr head; // head is a type listptr
listptr p ;
listptr next ;
head = NULL; //therfore make it null
next = NULL;
for(int i =0 ; i<4 ; ++i)
{
p = new list;// create new element of p type of listptr (new structure)
cin >> p->a;
cout << p->a <<endl;
}
p->link = next;
cout << p <<endl;
cout << next;
return 0;
}
Hey guys, struggling to make a 2nd pointer run after the first. So that it can hold the address of the 2nd to last node. Any suggestions? Whilst I've managed to create the pointer, I'm unsure how to assign the previous memory location to it.
Many Thanks,
John