I am creating a program where I convert all lower case to upper case and Second option is to capitalize first letter of each word. My issue is When I enter a sentences to convert it isn't outputting my function. Please help
int main()
{
constint length = 100;
char str[length];
int choice;
char again;
cout << "Welcome to the Character Converter class! " << endl;
do {
cout << "\n 1. Converted all lowercase letters to uppercase";
cout << "\n2. Convert the first letter of each word to uppercase\n\n";
cout << "What would you like to do?";
cin >> choice;
if (choice == 1)
{
cout << "Enter a sentence to convert";
cin.getline(str, length);
cin.ignore();
cout << upperCase(str);
}
elseif (choice == 2)
{
cout << "Enter a sentence to convert: ";
cin.getline (str, length);
cin.ignore();
cout << properWords(str);
}
cout << "\nDo you want to do this again?";
cin >> again;
cin.ignore();
} while (again == 'y' || again == 'Y');
}
string upperCase(char str[100])
{
int i = 0;
while (str[i] != '\0')
{
printf(" %c", toupper(str[i + 1]));
i++;
}
return str;
}
string properWords(char str[])
{
for (unsignedint i = 1; i < strlen(str); i++)
{
if (str[i] == ' ')
printf(" %c", toupper(str[i + 1]));
i++;
}
return str;
}