question about linked list
Nov 25, 2009 at 2:19pm UTC
i am writing a program.. using the structure and linked list.. but when i pass through the list, i want to "cout" the list, but i dunno how to call the data since i am using dynamic list...
here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include <iostream>
using namespace std;
int main()
{
struct node
{
int mark;
node *next;
};
node *head = 0;
int n;
cout << "Please enter marks: " ;
while (cin >> n)
{
cout << "Please enter marks: " ;
node *tmp = head;
head = new node;
head->mark = n;
head->next = tmp;
}
node *p = head;
while (p != 0)
{
cout << "mark = " << record.mark //<---how to print the marks?
<< endl << "pointer = " << p << "\n\n" ;
p = p->next;
}
system ("pause" );
return 0;
}
thx for attention!
Nov 25, 2009 at 2:30pm UTC
p->mark
Topic archived. No new replies allowed.