how to prevent my prog from crushing when the file im opening and reading data is not correct, i means if someone just make trash file and change it's name to some important file.
Posted on 2004-03-20 18:25:36 by AceEmbler
This may all depend of the structure of the file you expect to process. In some cases, you may be able to inspect its header, or its size, or something else before processing it. In other cases, you may be able to inspect each section of the file for valid data while you are processing it.

When errors are detected, you may end the program yourself instead of letting it crash on garbage data. Or you may want to inform the user that the file is improper and let the user terminate the program or supply another file.

Whenever you rely on user input or an outside source of data to run your program, a large part of the program should be geared to checking for potential errors. (Check my signature.)

Posted on 2004-03-20 22:11:43 by Raymond
You should also set up an exception handler.
Posted on 2004-03-20 22:53:04 by ENF

You should also set up an exception handler.

How can i do this ??
Posted on 2004-03-21 02:41:30 by AceEmbler
Hi AceEmbler,

Search for SEH (Structured Exception Handling) on the board. I have an example in GoAsm available on my website that gracefully exits on an error and you can also view the same code in MASM format in the FlipCase addin for RadASM. Jeremy Gordon has some excellent tutorials on the subject on his website with example code:
Posted on 2004-03-21 04:59:15 by donkey