a string in a linked list

Make a program that will prompt user to input a string in a linked lis

Page 1 of 1

2 Replies - 1673 Views - Last Post: 11 December 2010 - 05:16 AM Rate Topic: -----

#1 reckah irja xi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-December 10

a string in a linked list

Posted 10 December 2010 - 10:52 PM

Make a program that will prompt user to input a string in a linked list. The program also can add a list or can delete a list. The program also will display the linked list of strings.

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 :code:

Is This A Good Question/Topic? 0
  • +

Replies To: a string in a linked list

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: a string in a linked list

Posted 11 December 2010 - 12:26 AM

View Postreckah irja xi, on 11 December 2010 - 02:52 PM, said:

i have programs here but string is separated from linked list...


What does that mean?
You will need to describe your bug meaningfully if you want help
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,428
  • Joined: 23-August 08

Re: a string in a linked list

Posted 11 December 2010 - 05:16 AM

It's just copy/paste code from here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1