3

I'm trying to do IO using stdio.h on a Commodore 64, but I'm having with even the following program:

#include <stdio.h>

void main(void)
{
    printf("Foo\n");
    printf("Bar\n");
    /* printf("Foo\n"); */
    /* printf("Bar\n"); */
}

The problem is, if I leave 2 printfs uncommented, then it works as expected. If I uncomment all four, then it doesn't work at all: if I RUN it, I just see the lines flashing by before the screen resets to just showing READY. on an empty screen.

If I have three, then it doesn't work for the first time (flashes to empty READY. screen) but if I RUN it again, then it works...

I should add that I've only tested this on VICE, not a real C64.

Devolus
  • 21,661
  • 13
  • 66
  • 113
Cactus
  • 27,075
  • 9
  • 69
  • 149
  • Can you be more specific as to what you mean by "doesn't work at all"? – Devolus Dec 23 '13 at 10:46
  • what happens if you change main() return type to int and return 0 at its end? – Ali Alavi Dec 23 '13 at 10:55
  • @Devolus: Like I wrote, `RUN`ning it results in the showed lines quickly getting replaced by an empty screen with just a single `READY.` in the top-left corner. It's like as if after priting the lines, it also quickly executed a clearscreen instruction. – Cactus Dec 23 '13 at 10:56
  • @Lazarus: it doesn't seem to make any difference. – Cactus Dec 23 '13 at 10:58
  • Can you put a `sleep` or a `getch` at the end to see if this is after main. – Devolus Dec 23 '13 at 10:59
  • @Devolus: OK I'm starting to think my CC65 installation is FUBAR... if I replace `main` with `{ sleep(2); printf("Foo\n");}` then first it immediately (no 2 second wait) goes to the empty `READY.` screen, and if I try to run it again, VICE tells me it caused the CPU to jam.. – Cactus Dec 23 '13 at 11:23
  • 1
    User says works as expected now that expectations were clearer. – Jens Dec 23 '13 at 12:15

1 Answers1

4

After following @Devolus's suggestion to do sanity checking with sleep, it turned out nothing, in general, was working properly. I've downgraded my CC65 installation from 2.13.9-svn5804 to 2.13.3, and that seems to have solved my problem.

Cactus
  • 27,075
  • 9
  • 69
  • 149