Skip to content

Commit ab4be25

Browse files
authored
Merge pull request #64 from sadeem-albir/patch-6
Update reverse.c
2 parents 11bb243 + 2c1b8e6 commit ab4be25

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

chapter_4/exercise_4_13/reverse.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ void reverse(char str[])
2727

2828
str[j++] = c;
2929
}
30+
31+
// if whole reverse process is complete, reset the static variables to make this function reusable
32+
if (str[j] == '\0')
33+
{
34+
i = 0;
35+
j = 0;
36+
}
3037
}
3138

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

0 commit comments

Comments
 (0)