Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I don't know how to do the following because I don't know how to use the string array in C++. Please Help!!! Thanx!
#include <iostream.h>
#include <string.h>class pizza
{
private:
char** topping;public:
pizza(int cho);
display(int cho);
}pizza::pizza(int cho)
{
for(int i=0; i<cho; i++)
{
topping[i][] = new char[strlen(top[i][])+1];
strcpy(topping[i][], temp[i][]);
}
}pizza::display(int cho)
{
for(int i=0; i!=cho; i++)
for(int j=0; topping[i][j]!='\0'; j++)
cout<<topping[i][j]<<" ";
}void main();
{
char** top={top("Ham"), top("Pineapple"), top("Onion"), top("Meatball")};
char** temp;
int num;
int choice;count<<"Enter Number of topping: ";
cin>>num;
cout<<"\n1. Ham\n2. Pineapple\n3. Onion\n4.Meatball\n\n\nEnter num: ";
for(int i=0; i<num; i++)
{
cin>>choice;
for(int j=0; top[choice][j]!='\0'; j++)
temp[i][j]=top[choice][j];
}
temp.pizza(choice);
display(choice);
}

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |