c++ checking if braces match
<p>I've been asked as a bonus programming challenge to see if braces match in a random string or char like this: {1+1} this would return 1, while {1+1}) would return 0.
This is what I have so far but it doesn't seem to do anything. Any help would be great? thanks </p>

<pre><code>//bonus.cpp
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;queue&gt;
#include &lt;stack&gt;

using namespace std;

int checkBraces (string s)
{
    //int myLength = s.length();
    std::stack&lt;int&gt; stack;
    char d;

    for (int i = 0; i &lt; s.length(); i++)
    {
        char c = s[i];

        if (c == '(')
        {
            stack.push(c);
        }
        else if (c == '[') 
        {
            stack.push(c);
        }
        else if (c == '{')
        {
            stack.push(c);
        }

        else if (c == ')')
        {
            if (stack.empty())
            {
                return false;
            }
            else
            {
                d = stack.top();
                stack.pop();
                if (d != '(')
                {
                    return false;
                }
            }
        }

        else if (c == ']')
        {
            if (stack.empty())
            {
                return false;
            }
            else
            {
                d = stack.top();
                stack.pop();
                if (d != '[')
                {
                    return false;
                }
            }
        }
        else if (c == '}')
        {
            if (stack.empty())
            {
                return false;
            }
            else
            {
                d = stack.top();
                stack.pop();
                if (d != '{')
                {
                    return false;
                }
            }
        }
    }

    if (stack.empty()) return true;
    else return false;

}


int main()
{
    cout &lt;&lt; "This program checks brace ([{}]) matching in a string." &lt;&lt; endl;

    checkBraces ("{1+1}");

}
</code></pre>
