HOW TO HANDLE EXCEPTIONS IN C

Answer Posted / chandan

There is no try,catch(available in C++,java..) facility to
handle exception in C.but we can handle exception by
validating data come from outside into the program.
eg.. cosider this code
void main(){
int a,b,div;
scanf("%d,%d",a,b)
div=a/b;
printf("%d",div);
}
int this case , b might be zero that will generate an
exception.so we can avoid it by using if statement.
if(b==0)
print("plz enter non zero value");

In this manner only we can prevent exception in C..

Thank you

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a pragma?

660


What is "Hungarian Notation"?

631


What is sizeof in c?

563


how can f be used for both float and double arguments in printf? Are not they different types?

602


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1121






What is the condition that is applied with ?: Operator?

654


Explain the use of bit fieild.

702


Here is a neat trick for checking whether two strings are equal

558


What is enumerated data type in c?

615


How old is c programming language?

569


What is the difference between array_name and &array_name?

768


What do you mean by command line argument?

634


What is a struct c#?

595


Why should I use standard library functions instead of writing my own?

665


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

712