Skip to content

Commit

Permalink
Merge pull request #63 from sadeem-albir/patch-5
Browse files Browse the repository at this point in the history
Update variables.c
  • Loading branch information
ohkimur authored Mar 5, 2024
2 parents 7730dc5 + 37865c3 commit d7272a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chapter_4/exercise_4_06/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ int main(void)
break;

case VARGET:
push(var_buff[var - 'a']);
// Check if the variable has been assigned previously
if (var - 'a' <= (varindex - 1))
{
push(var_buff[var - 'a']);
}
else
{
printf("Error: undefined variable.\n");
}
break;

case '\n':
Expand Down

0 comments on commit d7272a2

Please sign in to comment.