How to find if all brackets are balanced (C) : <p>So I have an array full of brackets, for example :</p>

<p>1) (()())())((())(())</p>

<p>2) ()((()()))</p>

<p>Any open bracket ( '(' ) should also be closed by another one (')')</p>

<p>So for example 1) -></p>

<p>(()())())((())(()) -> (....)..)((..)(..)  -> ())(()() -> .)(.. , so the answer is no because from here we can see that not all of the brackets are balanced</p>

<p>For example 2) -></p>

<p>()((()())) -> .((..)) -> (()) -> (..) -> () -> .. , so here the answer is yes because all brackets are balanced. In this case, I would also like to print the positions of all couples of brackets that are balanced, for example :</p>

<p>1,2 &amp; 5,6 &amp; 7,8 &amp; 3,10 &amp; 4,9</p>

<p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
