Program using linked node lists and pointers, no idea how to complete it!!

Here is my program thus far (not even sure if I declared everything correct for ptr 2 and 3), now I am very bad with pointers and know even less about nodes. So, the function print_contents is supposed to take a pointer to a node and prints its info, so for like ptr2 it would print e17. Now the blank for loop I left is supposed to run through a list starting at ptr1 and we have to make it to work for any size list (not just 3).

#include <cstdlib>
#include <iostream>

struct tax_node
{
char form; // tax form letter
int version; // tax form number
tax_node *next; // pointer to next node
};

typedef tax_node* tax_ptr;

void print_contents (tax_node* ptr);

using namespace std;

int main(int argc, char *argv[])
{
tax_ptr ptr1, ptr2, ptr3, mover;

ptr1 = new tax_node;
ptr1 -> form = 'w';
ptr1 -> version = 2;
ptr1 -> next = ptr2;

ptr2 = new tax_node;
ptr2 -> form = 'e';
ptr2 -> version = 17;
ptr2 -> next = ptr3;

ptr3 = new tax_node;
ptr3 -> form = 'd';
ptr3 -> version = 6;

for ()


}

void print_contents (tax_node* ptr)
{

}
Topic archived. No new replies allowed.