title: Issues with assigning result of a function to a variable
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main() {
     string userInput;
     int stringSize = 0;
  
     userInput = "Hello";
  
     userInput.size() == stringSize;
  
     cout &lt;&lt; "Size of userInput: " &lt;&lt; stringSize &lt;&lt; endl;
  
     return 0;
  }
  </code></pre>
  
  <p>I am trying to get an output of 5, but it is returning 0. I can't figure out what's wrong. The <code>userInput</code> "Hello" should have a size of 5 and <code>userInput.size()</code> should return 5. This should be assigned to variable stringSize. Side note, can anyone explain to me why it is "==" not "="? If I try it with "=", it does not compile and I get this error:</p>
  
  <pre><code>main.cpp: In function ‘int main()’:
  main.cpp:11:23: error: lvalue required as left operand of assignment
      userInput.size() = stringSize;
                         ^~~~~~~~~~
  </code></pre>
  
  <p>My understanding is "=" is assignment and "==" is a Boolean comparison that is either "true" or "false" depending on if both sides are equal. I am trying to assign the size of <code>userInput.size()</code> into the variable so I would think that I should use "=". Maybe this is part of the problem? </p>