title: code has an if else condition but the code is not checking the conditon I think
body: <p>I have written this code for a question given as follows but i cant seem to find an error in it and it does not compile on online compilers as well as on vs code.If there is a logical error could you tell what it is? There are various solutions to this problem.I just want to know if this approach and logic is valid and if not what mistakes should be avoided so that code can be compiled.</p>
  <p>I am also writing my understanding of this code in comment if it is wrong please do correct me. So that i can learn it and avoid making this mistake in future.</p>
  <p><strong>question</strong>:      Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).</p>
  <p><strong>code</strong>:</p>
  <pre><code>#include&lt;iostream&gt;
  //using namespace std; if i use this then my next line could be written as (datatype variable)
  bool solution(std::string const &amp;str, std::string const &amp;ending)//&amp;str is the address.
   {
  
   if ( &amp;str.at(str.length()-1)== &amp;ending.at(ending.length()-1) || ending==&quot;&quot;)//reduce the length by one and that will be the value of the last character which can be checked . I have also declared if the ending string is null then what the condition should be.
    {
  return true;
    }
   else
    { 
    return false;
    }
  }
  
  int main()
  {
      string u=&quot;true&quot;;
      string y=&quot;flee&quot;;
      solution(u,y);
      return 0;
  }
  </code></pre>
  <p><strong>output</strong>(codewar):
  Expected: true
  Actual: false
  <strong>output</strong> (compiler):'null'</p>