Skip to content

Commit 8461723

Browse files
committed
add back clearStack function
1 parent 7ac6052 commit 8461723

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: chapter04/4-4.c

+9
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ void duplicateTop(void)
129129
push(top2);
130130
}
131131

132+
/* clearStacK: clear the stack */
133+
void clearStack(void)
134+
{
135+
sp = 0;
136+
}
137+
132138
/* reverse Polish Calculator */
133139
int main(void)
134140
{
@@ -174,6 +180,9 @@ int main(void)
174180
case 's':
175181
swapTopTwo();
176182
break;
183+
case 'c':
184+
clearStack();
185+
break;
177186
case '\n':
178187
printf("\t%.8g\n", pop());
179188
break;

0 commit comments

Comments
 (0)