CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    20

    Question 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?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    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.

  3. #3
    Join Date
    Mar 2009
    Posts
    20

    Re: How to get Input in 2D dynamic array??

    can u explain a bit please????

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: How to get Input in 2D dynamic array??

    Quote Originally Posted by arshad115 View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured