diff --git a/src/api.c b/src/api.c index 467d520..65d1a07 100644 --- a/src/api.c +++ b/src/api.c @@ -11,14 +11,18 @@ void api_put() { int mode = state->STACK[state->STACK_IDX--]; // 1 for char, 2 for num if (mode != 1 && mode != 2) return; + FILE *f = fstream; + if (f == stderr) + f = stdout; + if (mode == 1) { char c = state->STACK[state->STACK_IDX--]; if (c == '\0') c = ' '; - printf("%c", c); //using printf and not write because of the buffer + fprintf(f, "%c", c); //using printf and not write because of the buffer } else { - printf("%d", state->STACK[state->STACK_IDX--]); + fprintf(f, "%d", state->STACK[state->STACK_IDX--]); } }