title: Go word-by-word through a text file and replace certain words
body: <p>My intended program is simple: Take each word of a text file and replace it with asterisks if it's a swear word. For instance, if the text file was "Hello world, bitch" then it would be modified to "Hello world, <strong><em>*</em>****</strong>". </p>
  
  <p>I have the tool for taking a word as a string and replacing it with asterisks if needed. I need help setting up the main part of my program because I get confused with all the fstream stuff. Should I instead make a new file with the replaced words and then overwrite the previous file?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  const char* BANNED_WORDS[] = {"fuck", "shit", "bitch", "ass", "damn"};
  
  void filter_word(std::string&amp;);
  void to_lower_case(std::string&amp;);
  
  int main (int argc, char* const argv[]) {
  
      return 0;
  }
  
  void filter_word(std::string&amp; word) { 
      std::string wordCopy = word;
      to_lower_case(wordCopy);
      for (int k = 0; k &lt; sizeof(BANNED_WORDS)/sizeof(const char*); ++k) 
          if (wordCopy == BANNED_WORDS[k]) 
              word.replace(word.begin(), word.end(), word.size(), '*');
  }
  
  void to_lower_case(std::string&amp; word) { 
      for (std::string::iterator it = word.begin(); it != word.end(); ++it) { 
          switch (*it) { 
              case 'A': *it = 'a';
              case 'B': *it = 'b';
              case 'C': *it = 'c';
              case 'D': *it = 'd';
              case 'E': *it = 'e';
              case 'F': *it = 'f';
              case 'G': *it = 'g';
              case 'H': *it = 'h';
              case 'I': *it = 'i';
              case 'J': *it = 'j';
              case 'K': *it = 'k';
              case 'L': *it = 'l';
              case 'M': *it = 'm';
              case 'N': *it = 'n';
              case 'O': *it = 'o';
              case 'P': *it = 'p';
              case 'Q': *it = 'q';
              case 'R': *it = 'r';
              case 'S': *it = 's';
              case 'T': *it = 't';
              case 'U': *it = 'u';
              case 'V': *it = 'v';
              case 'W': *it = 'w';
              case 'X': *it = 'x';
              case 'Y': *it = 'y';
              case 'Z': *it = 'z';
          }
      }
  }
  </code></pre>