Re: fexception handling in C





Default User wrote:
> siliconwafer wrote:
>
> > Hi All,
> > I am using C on linux and performed a 1/0 operation i.e a divide by
> > zero using integer variables/constants.it gives me a floating point
> > exceptionand the program terminates.
> > I want to access the routine that causes this message to occour and
> > want to modify it so that my program continues to run.How is exception
> > handling done in C?Is there a try-catch equivalent?
> > Any help apriciated.
>
>
> Rather than try to handle the divide by 0, why not prevent it? You know
> where it's happening, add logic to test the operands and handle the
> situation.
>
>
>
> Brian

Hi Again,
Thanks for all your suggestions.I tried using signal() function.
It takes 2 args,a constant difining the type of signal and a function
pointer to signal handler.Can one pass more than one args to signal
handler?The signal function is defined as
void (*signal (int sig, void (*func)(int)))(int);
That is to say, signal is a function that returns a pointer to another
function. This second function takes a single int argument and returns
void. The second argument to signal is similarly a pointer to a
function returning void which takes an int argument.
Now signal() also returns a pointer to a function.But to which
function?Is it any user defined function or any C/system related
function?If so how can one use this return value?
some more help appriciated
Thanks,
-siliconwafer

.



Relevant Pages

  • Re: confusion: casting function pointers
    ... pointer from the 'actual/other modules' that takes arguments of type ... list to types of void *). ... int main{ ... without a prototype, a number of special "promotion" rules take ...
    (comp.lang.c)
  • Re: [RFC] timers, pointers to functions and type safety
    ... * they have callback of type void ... callback is called by the code that even in theory has no ... cast to unsigned long and cast back in the callback. ... number - not a pointer cast to unsigned long, not an index in array, etc. ...
    (Linux-Kernel)
  • Re: Can I Trust Pointer Arithmetic In Re-Allocated Memory?
    ... You can't do pointer arithmetic on a void* value. ... qsort behaves in a manner consistent with its specification. ... actually works as advertised...but doesn't mean that the cast is ...
    (comp.lang.c)
  • Re: The void** pointer breaking symmetry?
    ... void** is a generic pointer type that can be implicitly converted ... because dereferencing the void ** variable once gives ...
    (comp.lang.c)
  • Re: Maps, filters and accumulators
    ... void pointer they get back to a pointer to the appropriate type of data. ... int(*compar)(const void *, const void *)) ... avoid having to do all that work (either by getting a code generator to ...
    (comp.lang.c)