So, here's my code. I have to remove all 'a' and 'A' from the given text (which can be random) but here is the text block sample I'm given:
The quick brown fox jumps over a lazy dog. A cat ran away as the fox came around the bend. Further down the road, a student was ta- king an exam for his CS2433 class.
I've added a couple other cout's just to see along the way what's going on and it appears my cin is only taking in the "The" part of the given text to read in.
I'm not sure what's going on? The unix command I use to run the file with an input file is: ./hw5.out < hw5in.txt Should I use something different to pass in the string?
1 #include <iostream>
2 #include <algorithm>
3 using namespace std;
4
5 int main()
6 {
7
8 string str;
9 cin >> str;
10
11 char chars[] = "aA";
12 cout << str;
13 for (unsigned int i = 0; i < str.length(); i++)
14 {
15
16
17 str.erase (std::remove(str.begin(), str.end(), chars[i]), str.end());
18 }
19 cout << str;
20 for (int i = 0; i < str.length();i++)
21 {
22 if (str[i] == '\n')
23 {
24 str[i] = '\t';
25 }
26 }
27
28
29 cout << str;
30
31 }
UPDATE: I wrote out a while look with the getLine command concatenating each iteration into a variable "text" and then ran some of what my original code did, replacing all the str's with text. I appreciate the responses, I'll definitely being going through the repositories posted, thanks!