Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Line 2 is checking to see if the current character is the null terminator of the string - since C strings are null-terminated, and the null character is considered a false value, it will begin unrolling the recursion when it hits the end of the string (instead of trying to call StrReverse4 on the character after the null terminator, which would be beyond the bounds of the valid data).</p> <p>Also note that the pointer is to a <code>char</code>, thus incrementing the pointer only increments by 1 byte (since <code>char</code> is a single-byte type).</p> <p>Example:</p> <pre><code> 0 1 2 3 +--+--+--+--+ |f |o |o |\0| +--+--+--+--+ </code></pre> <ol> <li>When <code>str</code> = <code>0</code>, then <code>*str</code> is <code>'f'</code> so the recursive call is made for str+1 = 1.</li> <li>When <code>str</code> = <code>1</code>, then <code>*str</code> is <code>'o'</code> so the recursive call is made for str+1 = 2.</li> <li>When <code>str</code> = <code>2</code>, then <code>*str</code> is <code>'o'</code> so the recursive call is made for str+1 = 3.</li> <li>When <code>str</code> = <code>3</code>, then <code>*str</code> is <code>'\0'</code> and <code>\0</code> is a false value thus <code>if(*str)</code> evaluates to false, so no recursive call is made, thus going back up the recursion we get...</li> <li>Most recent recursion was followed by `putchar('o'), then after that,</li> <li>Next most recent recursion was followed by `putchar('o'), then after that,</li> <li>Least recent recursion was followed by `putchar('f'), and we're done.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload