title: What is wrong with my logic? Trying to count amount of words in a file that contain a specific character
body: <p>First time posting a question. Seeking debugging help. I am trying to figure out where my logic is wrong in a c++11 function. The goal is to search for a given character in a file and record the number words it is in, the number of lines it is in, and the number of times it appears in the file in total. Lines and total amount of occurrences are accurate but the word count is off which I assume is because of my logic. lwc is a class I created and has int set methods. Where am I going wrong to properly count the amount of words that has a specific character in it? Thanks for your time.</p>
  
  <pre><code>void findChar(lwc *CH, string File)
  {
  ifstream file(File);
  int a=0;
  int b=0;
  int c=0;
  string line;
  bool i = false;
  bool j = false;
  char ch;
  while (!file.eof())
  {
  
          getline(file, line);
          for (int g=0; g&lt;line.length(); g++)
          {       ch = line[g];
                  if (ch == CH-&gt;getChar()) //to count characters
                  {a++; i= true; j = true;}
  
                  if (isspace(ch) &amp;&amp; j) //to count words
                  {c++; j=false;}
          }
          if (i)                 //to count lines
          {b++; i = false;}
  
  }
  
  CH-&gt;setWords(c);
  CH-&gt;setChars(a);
  CH-&gt;setLines(b);
  
  }
  </code></pre>