Skip to content

Commit 37865c3

Browse files
authored
Merge branch 'main' into patch-5
2 parents c066b3f + ab4be25 commit 37865c3

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

chapter_4/exercise_4_04/stack.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ int getop(char s[])
215215
s[++i] = c = next;
216216
}
217217
}
218-
else
219-
{
220-
c = getch();
221-
}
222218

223219
if (isdigit(c))
224220
{

chapter_4/exercise_4_06/variables.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,7 @@ int getop(char s[])
304304

305305
return NUMBER;
306306
}
307+
/* To prevent the variable checking in getop() from overlapping with the letter commands,
308+
make sure you set the commands to capital letters and explicitly tell the getop() to only
309+
check for variable-getting if the character is not capital
310+
e.g insteat of "if (isalpha(c))" you add "if (isalpha(c) && !(c >= 'A' && c >= 'Z'))"*/

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)