Output not working correctly

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

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  int main()
	{
		const int 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);
			}
			else if (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 (unsigned int i = 1; i < strlen(str); i++)
		{
			if (str[i] == ' ')
				printf(" %c", toupper(str[i + 1]));
			i++;
		}
		
		return str;
	}
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <string>
#include <cctype>
#include <cstring>

using namespace std;

	string upperCase(char str[100]);
	string properWords(char str[]);
  int main()
	{
		const int 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; cin.ignore();
			
			
			if (choice == 1)
			{
				cout << "Enter a sentence to convert : ";
				cin.getline(str, length);
				cout << upperCase(str);
			}
			else if (choice == 2)
			{
				cout << "Enter a sentence to convert : ";
				cin.getline (str, length);
				cout  << properWords(str);
			}
			cout << "\nDo you want to do this again? : ";
			cin >> again;

		} while (again == 'y' || again == 'Y');

		cin.get();
		return 0;
	}

	string upperCase(char str[100])
	{
		int i = 0;
		while (str[i] != '\0')
		{
			str[i] = toupper(str[i]);
			i++;
		}
		return str;
	}

	string properWords(char str[])
	{
		int i = 0;
		bool thisCharacter = false;
		for (i = 0; i < strlen(str); i++)
		{
			if(thisCharacter == false)
			{
				if(isalpha(str[i])) 
				{
					str[i] = toupper(str[i]);
					thisCharacter = true;
				}
			}
			else if(!isalpha(str[i])) thisCharacter = false;
		}
		
		return str;
	}


http://cpp.sh/6husz
Thank you!!!!
Topic archived. No new replies allowed.