i have programs here but string is separated from linked list...
HELP!!!
linked list sample program
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
class visitor
{
char name[30];
char address[50];
long phone;
public:
visitor *next;
void getdata()
{
cout<<"\nEnter Details for New visitor\n";
cout<<"\nEnter The Name\n";
gets(name);
cout<<"\nEnter The Address\n";
gets(address);
cout<<"\nEnter Phone Number";
cin>>phone;
}
void putdata()
{
cout<<"\nName:"<<name<<"\nAddress:"<<address<<"\nPhone:"<<phone;
}
};
visitor *start=NULL,*ptr=NULL;
int main()
{
char ans;
cout<<"\nDo you want to create a New Vistor? Type Y/y for yes\n";
cin>>ans;
while(ans=='y'||ans=='Y')
{
visitor *newvisitor=new visitor;
if(start==NULL)
{
start=ptr=newvisitor;
newvisitor->getdata();
newvisitor->next=NULL;
}
else
{
ptr->next=newvisitor;
ptr=newvisitor;
newvisitor->getdata();
newvisitor->next=NULL;
}
cout<<"\nDo you want to create a New Vistor? Type Y/y for yes\n";
cin>>ans;
}
cout<<"\nDo you want to See the Linked List? Type Y/y for yes\n";
cin>>ans;
if(ans=='y'||ans=='Y')
{
for(ptr=start;ptr!=NULL;ptr=ptr->next)
ptr->putdata();
}
getch();
}
i have to pass this one brfore 1 hour...
Mod edit - Don't forget to

New Topic/Question
Reply




MultiQuote






|