hi im having problems with a doubly linked list. im trying to initialise three names into the list and print them straight off using the list and pointers but cant figure out how. heres what i have already if it could be modified i would greatly appreciate. also please keep the explanations simple as i have only recently started c++

#include <iostream.h>
#include <ctype.h>
#include <string.h>

void initialise(Name *&, char arr[], Name *&);
void DisplayList(Name *) ;
main()
{
Name * Head, * Tail ;
Name *Head = NULL,
*Tail = NULL;
Name *mvlr=NULL;

char s1[]="name1";
char s2[]="name2";
char s3[]="name3";

initialise(s1, Head, Tail);
initialise(s2, Head, Tail);
initialise(s3, Head, Tail);
DisplayList(Head) ;
}

void initialise(Name * &H, Name * &T)
{ H = T = NULL ;
}

void DisplayList(Name * H)
{ ListEntry *curr = H ;
if(H != NULL) {
do {
cout << curr->Name << endl ;
curr = curr->Next ;
}while(curr != H) ;
}
}

You've only just started C++ and you're trying to implement a doubly linked list? You might want to start out with a singly linked list first... Also, it's hard to see exactly what is supposed to be going on in your code without seeing the definition of Name

#include <iostream.h>
#include <ctype.h>
#include <string.h>

These should be

#include <iostream>
#include <cctype>
#include <string>
main()

to..

int main()
Name * Head, * Tail ;
Name *Head = NULL,
*Tail = NULL;

Error here - you can't redefine names. change to

Name * Head = NULL;
Name * Tail = NULL;
char s1[]="name1";
char s2[]="name2";
char s3[]="name3";

This is OK, but you might be making life difficult for yourself. I recommend you use the C++ std::string instead of C-Style null-terminated char arrays.

std::string s1("James");
std::string s2("Kevin"); //etc

There appears to be a load of other errors too, such as: cout << curr->Name << endl ; but it's impossible to tell what's going on without seeing what Name actually is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.