-
Notifications
You must be signed in to change notification settings - Fork 7
/
Exercise 3
47 lines (37 loc) · 1.23 KB
/
Exercise 3
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
// -----------------------------------------------------------------------------
//
// C11 - Exercise 3
/*
Write a program that removes all vowels from a file ("disemvowels"). For example,
Once upon a time! becomes nc pn tm!. Surprisingly often, the result is still
readable; try it on your friends. (I would if I had any)
The resulting file will read like a text message from 2003. Horrendous.
*/
// -----------------------------------------------------------------------------
//--INCLUDES--//
#include "std_lib_facilities.h"
// -----------------------------------------------------------------------------
string disemvowel(string s)
{
size_t pos = s.find_first_of("aeiouAEIOU");
while (pos != string::npos)
{
s.erase(pos, 1);
pos = s.find_first_of("aeiouAEIOU");
}
return s;
}
// -----------------------------------------------------------------------------
int main()
{
ifstream readIn{ "inputFile.txt" };
stringstream ss;
ss << readIn.rdbuf(); //read entire file into stringstream in one go
string file1 = ss.str(); //convert stringstream to string
file1 = disemvowel(file1);
cout << file1;
cout << endl;
keep_window_open();
return 0;
}
// -----------------------------------------------------------------------------