How do I set a string value inside an if statement? (C++) : <p>This may seem like a stupid question but how do I keep a variable value when it is assigned inside a if statement?
For example:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;
int main()
{
    string usability;
    string bent;
    string usable;
    string input = "bent";

    if(input.find(bent) != string::npos)
    {
        string usability = "bent";
    }
    if(input.find(usable) != string ::npos)
    {
        string usability = "usable";
    }    

    cout &lt;&lt; usability;
    return 0;
}
</code></pre>

<p>The string usability at the end is still empty. (I assume because the variable is only set in its own if statement?) How do I get it to print "bent" or "usable"?</p>

<p>Thanks</p>
