1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-05 12:06:10 +00:00
C02/vic20/fgetc.c02
2018-01-28 13:57:49 -05:00

68 lines
1.3 KiB
Plaintext

/*************************************
* fgetc.c02 - test file.h02 Library *
* function fgetc() *
*************************************
load "fgetc.prg",8
*/
#include <vic20.h02>
#include <stdlib.h02>
#include <stdio.h02>
#include <string.h02>
#include <file.h02>
char fp; //File Pointer
char filnam = "TESTFILE.SEQ";
char buffer[128];
char c;
main:
//Print Banner
putchr(147); //Clear Screen
putchr(18); //Reverse On
putstr(" TEST FGETC ");
//Initialize File System
fsinit();
//Open File
newlin();
fp = fopen(8, &filnam);
if (fp) {
outstr("CHANNEL ");
ctoa(fp, &buffer);
outstr(&buffer);
putstr(" OPENED TO ");
putstr(&filnam);
}
else {
prterr();
putstr(" OPENING FILE");
putstr(&filnam);
goto exit;
}
//Print File Contents
newlin();
putstr("FILE CONTENTS:");
while (!feof(fp)) {
c = fgetc(fp);
putchr(c);
}
newlin();
//Close File
if (fclose(fp)) {
prterr();
putstr(" CLOSING FILE");
putstr(&filnam);
}
goto exit;
void prterr() {
outstr("ERROR ");
ctoa(fstat(0), &buffer);
outstr(&buffer);
}