two dimension array

I am tring to set up a 2x10 two dimensional array that holds two seperate strings (char firstName and char lastName) for the two columns and i want to store up to 10 people (rows). I want the user to enter in the names and be able to display the names after they are typed in. I am unsure how to set up the char array and I am unsure how to have the user enter the names. Any information that will help me code this will be thankful

I would think:
char *names[10][2]; // will need to dynamically allocate memory space for each name
or
char *names[10][2][15]; // static allocation, assuming no name over 14 letters

In effect, you'll have a 3-dimensional array, when you figure that each element of your 2D array will itself be a 1D array.

How the user will input the names depends in part on whether you're using C or C++. In C++, it seems popular now to use iostreams:
cin >> firstName >> last Name;

Then strcpy those strings into the appropriate elements of the array. Of course, if you are using the dynamic allocation approach, be sure to allocate one character more than the string length for the null terminator.

Originally posted by wizard2468 For the record this is not homework. I am learning C++ on my own with the books you can buy at any bookstore.

Pardon our assumptions. It's just that we tend to get a lot of students looking for help with their homework. I don't mind tutoring, but I'm reluctant to just give an answer. If it just gets done for them, then they won't learn.

Originally posted by wizard2468 The code that I have been working with is not right but here it is

With this code it allowed me to enter 10 names but it wou't display them

There was a discussion here, about a month ago, about a problem with getline(). IIRC, it has to do with how it handles (or doesn't quite handle) the newline.

Now, since name is a two-D array and a string would only go into a 1-D array, you should do that:
cin >> name[i];
And the same when you output it. You would probably either want to echo it out immediately or write a second for-loop to output the contents of the array. Preferably the latter, I would think.

One further note. Both the << and >> operators are overloaded, which means that they will run different code depending on the data-type/class being output or input. That is why they handle char* differently than int or double.

Your code as it stands is telling them to handle a char** . I personally have difficulty believing that the iostream library writer would have written a method to handle a char**, but apparently they did because it does compile (doesn't it?). Still, I have no idea how it would actually be trying to handle it. Unless the character data being input was being interpreted as a pointer [shudder!].