 <p>In addition to what cygin points out (parameters seem reversed), <code>revStr</code> calls itself with a <em>smaller</em> value for <code>e</code>. But your description sounds like <code>e</code> is supposed to be less than or equal <code>k</code>. So then wouldn't you want to pass a <em>larger</em> value for <code>e</code>? Otherwise I don't see why you would ever reach <code>k</code>.</p> <p>As a side comment, I wonder why a substring function is named <code>revStr</code>.</p>