[cc65] First Try of CBM File-IO

Date view Thread view Subject view

From: udo klasmeier (uklasmeier_at_t-online.de)
Date: 2001-08-13 17:36:24


Hi here is my first try. It works fine for the first time.
If i run it another time it refuses to overwrite the existing
file. The C64-Basic Method for it ( a leading @: ) does not
seem to work.
I tested it with VICE ( under LINUX ) i assume its not a compiler
error unless the filename is modified by the compiler.

Does anybody know a trick to get around that problem?
Udo

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <fcntl.h>
#include <dbg.h>

void mygets(char *s,int sz){
int i,c;
 cursor(1); 
 for(i=0;i<sz;i++){
  c=cgetc();
  if(c=='\n') break;
  cputc(c);
  s[i]=c;
 }
 s[i]=0;
}

int main (void){
char buf[128];
 clrscr();
    textcolor (COLOR_WHITE);
    bordercolor (COLOR_BLACK);
    bgcolor (COLOR_BLACK);
 printf("\nStart of Version 1\n");
 printf("Question: ");
 mygets(buf,128);
 printf("\nYou gave %s\n",buf);
 cbm_open(2,8,2,"@:test17.dat,s,w");
 cbm_write(2,buf,strlen(buf));
 cbm_close(2);
 return EXIT_SUCCESS;
}






----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:41 CET