HOW TO HANDLE EXCEPTIONS IN C

Answers were Sorted based on User's Feedback



HOW TO HANDLE EXCEPTIONS IN C..

Answer / 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

HOW TO HANDLE EXCEPTIONS IN C..

Answer / azhar iqbal

I prefer to get help in this matter.

Is This Answer Correct ?    2 Yes 1 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / bhupendra

i can not handle exception in C.When exception occue in C
the sustem will terminated.

Is This Answer Correct ?    2 Yes 2 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / eok

in C you dont have the luxury of the try and catch , unless
you get a non standard library
There is a way to handle errors
C works directly with the machine , so you must make a
function that will take whatever is causing the problem in
the buffers and remove it or clear the buffer altoeghter ,
although clearing the entire buffer can be over zealous

try using ungetc to remove stray pieces from the buffer

but again this really comes down to what error your trying
to deal with

also look at perror and strerror and the libraries errno.h
and stderr.h

hope this helped

Is This Answer Correct ?    0 Yes 0 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / vrushali

i feel perror would work for it..
please corect me if i m wrong

Is This Answer Correct ?    0 Yes 1 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / sivakumar

I was searching for this answer for a long time but I
couldn't get it so pls guide me if possible.....

Is This Answer Correct ?    0 Yes 1 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / padma

c dont have that much capacity to handle errors...

Is This Answer Correct ?    0 Yes 2 No

HOW TO HANDLE EXCEPTIONS IN C..

Answer / chandan kiit

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 ?    0 Yes 4 No

Post New Answer

More C Interview Questions

main() { int a; a=++100; printf("%d",a); getch(); }

4 Answers  


If I have a char * variable pointing to the name of a function ..

0 Answers  


Why is c so important?

0 Answers  


What happens if you free a pointer twice?

0 Answers  


c program to arrange digits in a no in ascending and descending order

1 Answers  






what value is returned to operating system after program execution?

0 Answers  


Why void is used in c?

0 Answers  


Is double link list a linear data structure? If Yes, Why?If No, Why?

4 Answers  


Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.

0 Answers  


Why can arithmetic operations not be performed on void pointers?

0 Answers  


What are header files and what are its uses in C programming?

0 Answers  


Are the outer parentheses in return statements really optional?

0 Answers  


Categories