Not understanding functions with two dimensional arrays

I'm new to C++, so far have been doing good with my assignments. Now I have a problem understanding functions with arrays.
Homework is to read in names into two dimensional arrays, print them in order they were typed and then sort and print them in alphabetical order.
My program works perfectly as it is but I need to create two functions to read in the names and sort the names.I don't know how to do it with two dimensional arrays.
Here's what I have so far, I would appreciate any feedback. I'm not looking for quick fix, I want to learn to understand how to do this, if someone could just point out mistakes that i need to fix
Thanks!
this is the function to read in names:

void Get(char **A, int N )
{
int i;
const int MNames=20;
const int MChar=15;


for (i=0; i<N; i++)
cin.getline(A[i], MChar);
}
Can you post your full code? Use the buttons on the right of the dialogue box to post it all proper-like.

Homework is to read in names into two dimensional arrays, print them in order they were typed and then sort and print them in alphabetical order.


I don't follow this. Homework is to read in names? Into arrays? Sounds like a user defined dynamic array, for which you can use the new and delete functions. Here is an example of a 1d array that resets with each use, and populates the array based on user input:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 	
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main( )
{ 
  srand( time(0) );

  unsigned int nFlips = 1;
  unsigned int nHeads = 0;
  unsigned int* results;

  while(nFlips != 0 )
  {
    cout << "How many times do you want to flip the coin?" << endl;
    cout << "(enter 0 (zero) to exit)" << endl;
    cin >> nFlips;

    if( nFlips > 0 )
    {
      results = new unsigned int[nFlips];
      nHeads = 0;

      for( unsigned int i=0; i < nFlips; i++ ) //flip the coin 
      {
        if( rand()%2 == 1 ) //1=heads 0=tails
          nHeads++;
      }
      
      cout << "Heads called " << ((double)nHeads/(double)nFlips)*100;
      cout << "% of the time." << endl;

      delete [] results;
    }
  }
  return 1;
}
Topic archived. No new replies allowed.