I'm working on a side assignment for fun and want to capitalize the output from whatever the user entered using ::toupper but I'm struggling. This is what I have so far;
#include <cctype>
#include<iostream>
#include<iomanip>
#include <string>
using namespace std;
int const ROWS = 4;
int const COLUMNS = 3;
void userInputValues(string myArray[ROWS][COLUMNS]);
void printValues(const string myArray[ROWS][COLUMNS]);
int main()
{
string myArray[ROWS][COLUMNS];
userInputValues(myArray);
printValues(myArray);
return 0;
}
void userInputValues(string myArray[ROWS][COLUMNS])
{
int index = 0;
cout << "Enter 12 names" << endl;
for(int row = 0; row < ROWS; ++row)
{
for(int column = 0; column < COLUMNS; ++column)
{
cout << ++index << ". Enter a name: ";
getline(cin, myArray[row][column]);
}
}
cout << endl;
}
void printValues(const string myArray[ROWS][COLUMNS])
{
for (int row = 0; row < ROWS; ++row)
{
for (int column = 0; column < COLUMNS; ++column)
{
cout << setw(3) << ::toupper (myArray[row][column]) << " ";
}
cout << endl;
}
}
When I run the code I get, "error: cannot convert ‘const string {aka const std::basic_string}’ to ‘int’ for argument ‘1’ to ‘int toupper(int)’" Which I sort of get because I can't pass a string as an int. But idk where to go from there. Also, I'm not too familiar with toupper since I never learned about so any help is appreciated.