F
fred
Hello,
I read a file from several classes and want to catch an EOF when it
appears.
Having caught the EOF I want to allow the final part of the program to
continue rather than just exiting.
At present I use methods which read from the file; test the read was
successful and return a 1 if not. This is then checked by the calling
method, which also returns a 1 if the other method returned 1 (thus
indicating the EOF) and so on...
As you can see, this is very clumsy and means that I have to
constantly check the return value. Sometimes this value is almost
passed back to main() several class levels away!
Also, where I use unsigned char methods, I do not know what character
to allocate to the EOF flag to return.
Does anyone know of a better design for this type of EOF catching?
Cheers
Fred
I read a file from several classes and want to catch an EOF when it
appears.
Having caught the EOF I want to allow the final part of the program to
continue rather than just exiting.
At present I use methods which read from the file; test the read was
successful and return a 1 if not. This is then checked by the calling
method, which also returns a 1 if the other method returned 1 (thus
indicating the EOF) and so on...
As you can see, this is very clumsy and means that I have to
constantly check the return value. Sometimes this value is almost
passed back to main() several class levels away!
Also, where I use unsigned char methods, I do not know what character
to allocate to the EOF flag to return.
Does anyone know of a better design for this type of EOF catching?
Cheers
Fred