Compare string and array c++ : <p>Im trying to compare the character count of a string with the index elements of an array, but am having trouble.
For example, if the userInput equals XX, the output should be:</p>

<p>XX is not in the array at position 0.</p>

<p>XX is in the array at position 1.</p>

<p>XX is not in the array at position 2.</p>

<pre><code>arr[] = {"X", "XX", "XXX"};
string userInput;
cin &gt;&gt; userInput;

    for (int i = 0; i &lt; userInput.length(); i++)
{
    if (userInput[i] == arr[i])
    {
        cout &lt;&lt; userInput &lt;&lt; " is in the array at position " &lt;&lt; i &lt;&lt; endl;
    }
    else
    {
        cout &lt;&lt; userInput &lt;&lt; " is not in the array at position " &lt;&lt; i &lt;&lt; endl;
</code></pre>

<p>Im recieving this error and am not sure how to fix it. Im fairly new to programming so any help would be great. Thank you.</p>

<p>Invalid operands to binary expression ('int' and 'string' (aka 'basic_string, allocator >'))</p>
