Any additions for write-to-file short program

Stanislav Blinov stanislav.blinov at gmail.com
Thu Nov 18 23:34:38 UTC 2021


On Thursday, 18 November 2021 at 22:20:48 UTC, pascal111 wrote:
> In next program that rewrites original written texts into new 
> files, I see that it may need some additions or we can accept 
> it like this because it's just a simple program that achieve 
> its task and doesn't need any philosophical additions.

If "the task" is to copy a file, then this program, as presented, 
may fail at it. If you're going to do any exception handling at 
all, a question must be answered: what to do in case the 
algorithm is interrupted before completing? I.e. if the `while` 
loop throws an exception, which it can do on any line except for 
braces. Is it acceptable to leave the output file containing only 
part of input data, perhaps even no data at all? Or should you 
catch the exception and delete the output file? Will that even be 
possible?..



More information about the Digitalmars-d-learn mailing list