NEED HELP FAST

I need to know how to make one function that calls multiple functions. This is the code I have so far.

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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//CS 575, Lab Exercise, Stefan Olarte

#include <iostream>
#include <string>
using namespace std;

// call the other 3 (or 4 if extra credit) funcs,
//     so f( "CS 1505 Pierce College" ) returns
//     "cs####pIERCEcOLLEGE" (full credit)
//     "cs####pIERCEcOLEGE" (extra credit), or
//     "cs#pIERCEcOLEGE" (extra credit)
string f(const string & s);
string removeSpaces(const string & s);
string changeCase(const string & s);
string redactDigits(const string & s);

// extra credit
// replace consecutive occurrences of the same char
//     with a single occurrence
// e.g. removeRepetitions( "Molly  greeted 11112 guests" )
//     returns "Moly greted 12 guests"
string removeRepetions(const string & s);


int main() {
	cout << "Spaces removed: " << endl;
	cout << removeSpaces("CS 1505 Pierce College") << endl;
	cout << endl;

	cout << "Cases changed: " << endl;
	cout << changeCase("CS 1505 Pierce College") << endl;
	cout << endl;

	cout << "Repititions removed: " << endl;
	cout << removeRepetions("aaabbbccddeefgg") << endl;
	cout << endl;

	cout << "Digits changed: " << endl;
	cout << redactDigits("4 pizzas and 87 beers") << endl;
	cout << endl;

	cout << "All combined: " << endl;
	cout << f("CS 1505 Pierce College") << endl;
	cout << endl;

}

string changeCase(const string & s) {
	string ret;
	for (unsigned pos = 0; pos < s.size(); pos++) {
		if (s[pos] >= 'a' && s[pos] <= 'z')
			ret += (s[pos] - 32);
		if (s[pos] >= 'A' && s[pos] <= 'Z')
			ret += (s[pos] + 32);
		if (s[pos] < 'A')
			ret += s[pos];
		
		}
		return ret;
	}


string removeSpaces(const string & s) {
	string ret;
	for (unsigned pos = 0; pos < s.size(); pos++)
		if (s[pos] != ' ')
			ret += s[pos]; // same as    ret = ret + s[pos]
	return ret;
}

string removeRepetions(const string & s) {
	string ret;
	for (unsigned pos = 0; pos < s.size(); pos++)
		ret += s[pos];
	return ret;
}

string redactDigits(const string & s) {
	string ret;
	for (unsigned pos = 0; pos < s.size(); pos++) {
		if (s[pos] >= 48 && s[pos] <= 57)
			ret += '#';
		else
			ret += s[pos];
	}
	return ret;
}

string f(const string & s) {
	return string removeSpaces(const string & s);
	return string changeCase(const string & s);
	return string redactDigits(const string & s);
}


I need string f(const string & s) to do all 3 of those functions but I can't figure out how..Please help. I've tried multiple ways.
1
2
3
4
5
6
string f(const string & s) {
    string result = removeSpaces(s);
    result = changeCase(result);
    result = redactDigits(result);
    return result;
}


or, if you're feeling frisky:

1
2
3
string f(const string & s) {
    return redactDigits(changeCase(removeSpaces(s)));
}
Topic archived. No new replies allowed.