Writing a program for homework that involves sorting names in a 2D array using bubble sort.. I need help/direction getting the entry of names "entered" started. I don't understand my errors when compiled. I am trying this:
int main()
{
int i = NumberofNames;
cout << "How many names do you wish to enter? " << endl;
cin >> NumberofNames;
const int NumRows = 1;
int NumCols = NumberofNames;
char NamesEntered;
int length = 15;
char ** NameArray [] [];
NameArray = new int [NumberofNames, 15];
cout << "Please enter " << NumberofNames << " names: \n" << endl;
cin << NamesEntered;
cout << "You entered: " << NamesEntered << endl;
2. char** NameArray[][]; is an illegal declaration, but correcting it isn't what you want,
since that declaration is attempting to declare a 4D array.
3. new int[ NumberOfNames, 15 ]; again NumberOfNames is not declared, but even if
it was, this isn't what you want, since it will create a dynamically allocated array of 15
elements regardless of the value of NumberOfNames.
Fixed what was suggested, but still not sure how to get this to copy my names I enter, and get it to repeat those names entered. It seems it's set to whatever number you enter...
int main()
{
int NumberofNames;
cout << "How many names do you wish to enter? " << endl;
cin >> NumberofNames;
It is taking in the amount of responses, and only displaying one letter a multiple of times. How can I change it up to read in each name. So if I choose 3, read in "Jim, Bob, Joe", and then reitterate my answer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
int NumberofNames;
cout << "How many names do you wish to enter? " << endl;
cin >> NumberofNames;
char ** NameArray;
constint NumRows = 1;
char NumCols = NumberofNames;
char length = 15;
NameArray = newchar * [NumRows <= length];
cout << "Please enter " << NumberofNames << " names: \n";
for (int i = 0; i < length; i++)
cin >> NumCols;
cout << "You have entered: \n" << endl;
for (int j = 0; j < length; j++)
cout << " " << NumCols;