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

explain how do you use macro?

0 Answers  


What is use of bit field?

0 Answers  


With the help of using classes, write a program to add two numbers.

0 Answers   TCS,


Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?

1 Answers   Microsoft,


why the execution starts from main function

9 Answers  


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


How does normalization of huge pointer works?

0 Answers  


can anyone suggest some site name..where i can get some good data structure puzzles???

0 Answers  


The code is::::: if(condition) Printf("Hello"); Else Printf("World"); What will be the condition in if in such a way that both Hello and world are printed in a single attempt?????? Single Attempt in the sense... It must first print "Hello" and it Must go to else part and print "World"..... No loops, Recursion are allowed........................

14 Answers   HOV Services, IBM, Potty,


extern static int i func() { i =10; i++; printf("%d \n",i); } main() { i =20; printf("%d \n",i); func(); printf("%d \n",i); }

2 Answers  


How do we swap or interchange any 2 numbers without using Temporary variable...Anybody can pls answer it.. Thanks in Advance

8 Answers  


What do you mean by Recursion Function?

0 Answers   Hexaware,


Categories