|
-
March 8th, 2009, 10:30 AM
#1
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?
-
March 8th, 2009, 10:52 AM
#2
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.
-
March 8th, 2009, 11:22 AM
#3
Re: How to get Input in 2D dynamic array??
can u explain a bit please????
-
March 8th, 2009, 11:45 AM
#4
Re: How to get Input in 2D dynamic array??
 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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|