Includestring include cstdlib using namespace std int

  • No School
  • AA 1
  • 8

This preview shows page 7 - 8 out of 8 pages.

#include<string> #include <cstdlib> using namespace std; int main() { //variables ifstream in_stream; ofstream out_stream; string list[20]; char letter; int index = 0; //open the input data file in_stream.open("in.txt"); //creating a file for output out_stream.open("out.txt"); cout << "Enter the letter you want to remove.\n"; cin >> letter; //if file to check if file opens if (!in_stream.fail()) {
Image of page 7

Subscribe to view the full document.

while (!in_stream.eof()) { getline(in_stream, list[index]); index++; } } //exiting the code if it doesnt open else { cout << "Failed to open, exiting code" << endl; exit(1); } for (int i = 0; i < index; i++) { for (int j = 0; j < list[i].length(); j++) { char test; test = list[i].at(j); if (tolower(test) == letter || toupper(test) == letter) { //Do nothing } else { //outstream so that you dont have to open file to view cout << list[i].at(j); //out.txt file out_stream << list[i].at(j); } } } //closed files in_stream.close(); out_stream.close(); return 0; }
Image of page 8
  • Fall '19
  • Void type, Carriage return

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes