Skip to content

Commit

Permalink
Merge pull request #64 from sadeem-albir/patch-6
Browse files Browse the repository at this point in the history
Update reverse.c
  • Loading branch information
ohkimur authored Mar 5, 2024
2 parents 11bb243 + 2c1b8e6 commit ab4be25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chapter_4/exercise_4_13/reverse.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ void reverse(char str[])

str[j++] = c;
}

// if whole reverse process is complete, reset the static variables to make this function reusable
if (str[j] == '\0')
{
i = 0;
j = 0;
}
}

// NOTE: As a simple observation when recursive functions are used, static
Expand Down

0 comments on commit ab4be25

Please sign in to comment.