How to get Input in 2D dynamic array??
i m making a hotel database management system and i have to add records, update and delete them.i m having problem in getting the input,how will i use double pointers?? and i have to get a certain number of records from the user.
here is my code:
Code:
void addcustomer()
{
int n;
cout << " ------- Add Customer Record --------" << endl << endl;
cout << "Please Enter the number of records you want to Enter: " << endl;
cin>>n;
char ** c=new char*[n];
cout << "Please Enter Customer Name: " << endl;
// dont know how to get input!
cout << "Please Enter Customer NIC Number: " << endl;
cout << "Please Enter Customer Telephone: Number " << endl;
cout << "Please Enter Customer Room Number: " << endl;
cout << "Please Enter Customer Entry Date and Time: " << endl;
cout << "Please Enter Customer Exit Date and Time: " << endl;
cout << "Please Enter Customer Payments: " << endl;
cout << "Please Enter Customer Status: " << endl;
}
how would i get input in the 2d array?
and one more thing,if i get input in one function,would i be able to use the same record in another function?
Re: How to get Input in 2D dynamic array??
Well, first, you should actually *have* a 2D array. Right now you only have an array of pointers.
Re: How to get Input in 2D dynamic array??
can u explain a bit please????
Re: How to get Input in 2D dynamic array??
Quote:
Originally Posted by
arshad115
can you explain a bit please????
Code:
char ** c=new char*[n];
c[0] is a char pointer that points nowhere.
Code:
c[0] = new char[255];
Now it points to a block of 255 chars.