in my program

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

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

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

		cout<<" Enter Y/N ";


	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.....

Recommended Answers

All 2 Replies

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

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');
Be a part of the DaniWeb community

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