title: Using a logical NOT, !, versus not using it
body: <p>I have a function that reads lines from a file and stores each string in each line in a vector.</p>
  
  <pre><code>void openf(std::string s)
  {
  std::string line;
  std::string b;
  std::ifstream in;
  in.open(s);
  std::vector&lt;std::string&gt; vec;
  if(in.is_open()) {
      std::cout &lt;&lt; "File is open\n" &lt;&lt; std::endl;
      while(std::getline(in,line)) {
          for(decltype(line.size()) i = 0; i != line.size(); ++i) {
              if(isspace(line[i]) || ispunct(line[i])) {
                  vec.push_back(b);
                  b = "";
              }
              else {
                  b += line[i];
              }
          }
      }
  }
  for(auto a:vec)
      std::cout &lt;&lt; a &lt;&lt; std::endl;
  in.close();
  }
  </code></pre>
  
  <p>This WORKS.</p>
  
  <p>But if instead I do this</p>
  
  <pre><code>if(!isspace(line[i]) || !ispunct(line[i])) {
      b += line[i];
  }
  else {
      vec.push_back(b);
      b = "";
  }
  </code></pre>
  
  <p>Nothing prints.</p>
  
  <p>If I don't have the logical OR statements, and just use !isspace and !ispunct individually the program behaves as it expects in the respective cases.</p>
  
  <p>I don't think I am required but I also tried putting () around each operator so it wouldn't interfere with the other each other. Still won't work.</p>
  
  <p>It seems like the same code. Why won't it work in one case and while it works in another?</p>