Slimelite BBS

EOF

Back to R25C

From Bill Birrell · 1996-04-05 16:54 · #75230 in R25C

In reply to EOF by Alistair Green

Hey Alistair,

 > I have recently been writing a program that involves
 > reading ascii files one
 > byte at a time. This is fine until I reach a section
 > of the code in the file
 > that is recognised as the EOF, even though it is not
 > the end of the file. The
 > program then doesn't see any more of the file. I was
 > wondering if anyone knows
 > of a way to get round this problem. Any help would be
 > much appreciated.

    Oh ... the old CP/M end of file marker (0x1a, Ctrl-Z, 26 or what have you).

    An easy one to solve. Open the file in binary mode, not text mode, and that problem should vanish into thin air. Eight-bit binary unsigned char storage can happily hold seven-bit ASCII chars.

    E.g. FILE *fp=fopen(filename,"rb"); or int fd=open(filename, O_RDONLY | O_BINARY); or FILE *fp=_fsopen(char *filename, "rb+",_SH_MODE);

Regards,
Bill.

---
 * Origin: bill@escan.demon.co.uk (2:2504/200)