0

in my program

class list    ///  list class
{
private:
             int *Data;
             int Size;
             num;
public:
                list()  // constructor 
               {
                    size =  1;
                    num = 0;
                }             
             
             void add();  // member function
};



void list::add()   /// 
{
     char choice;   

      do
      {
        	Data = new int[size];
		cout<<" \n Enter item  ";

		cin>>Data[num];
		num++;
                size++;
		
		cout<<" Enter Y/N ";
		cin>>choice;

      }

	while(choice == 'y');

}

and i called the function in main , its working . but here items is storing in

int *Data; // int data type...

I want to store strings . how to create a dynamic string array to store items name
( to store infinite items )
plz help me.....

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by raul15791
0

I don't really understand what you want.
Strings(c++) and chararrays(c) can be arbitrarily long.

So do you want a datastructure to hold an infinite amount of different strings?

You need to elaborate on your problem

0

Use string or character array as data type.
Then use cin.getline() to get input from user.

while (choice == 'y');

It would be better to change this line to:

while (tolower(choice) != 'n');
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.