www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/25/13:05:31

From: Waldemar Schultz <schultz AT ma DOT tum DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: exception handling.
Date: Mon, 25 Oct 1999 17:43:45 +0200
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Lines: 68
Distribution: world
Message-ID: <38147AB0.32EB329@ma.tum.de>
References: <B0000106271 AT stargate DOT astr DOT lu DOT lv>
NNTP-Posting-Host: pcritter1.mathematik.tu-muenchen.de
Mime-Version: 1.0
X-Mailer: Mozilla 4.6 [de] (Win95; I)
X-Accept-Language: de,en-US
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

The following program compiled wit gcc 2.95.1 produces
the following output when ^C was hit:

0
NaN
NaN
CtrlBreak 295

But I'd have epected something like:

0
errno xxx
NaN
errno xxx
NaN
CtrlBreak 295

Any explanation please ??

=======================

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>

void FloatError(int sig)
{
 printf("errno %d\n",sig);
}

void CtrlBrk(int sig)
{
 printf("CtrlBreak %d\n",sig);
}

void (* fp)(int);

int main(int argc, char *argv[])
{
//double x=NAN,y=NAN,z=NAN;
double x,y,z;

 fp=CtrlBrk;
 signal(SIGINT,fp);   /* ctrl-break     */

 fp=FloatError;
 signal(SIGFPE,fp);

 y=z*x;
 printf("%g\n",y);
 z=0.0;
 x=y/z;
 printf("%g\n",x);
 y=sqrt(-1.0);
 printf("%g\n",y);
 getch();

 return 0;
}

--
 Waldemar Schultz.
 Technische Universität München, Zentrum Mathematik M1, D 80290 München
 Tel: +49 (0)89 2892 8226        FAX: +49 (0)89 2892 8228


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019