linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J." <mailing-lists@xs4all.nl>
To: linux-c-programming@vger.kernel.org
Subject: strtod() and errno question.
Date: Tue, 10 Jan 2006 22:42:46 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.21.0601102235490.1799-100000@hestia> (raw)

Tuesday, January 10 22:35:50

Hi people,

I have a question regarding errno and strtod() error checking. I have a
function [listed below] that extracts a number from a string. In case of
an error, strerror() in conjunction with errno is used to display a user
friendly error message. However on a strtod() error; `Success' is
returned.

Error - strtod(ca4)`c': Success

Since I am a bit confused by the strtod() manual page, what would be the 
correct way to handle this ?

Thankx !

J.

int extrnumber(char *str) {
 int retv = 0;
 char *nptr = NULL;

 retv = strtod(str, &nptr);
 if(retv == 0 && nptr != NULL) {
  fprintf(stderr, "%s: Error - strtod(%s)`%c': %s\n", PACKAGE, 
    str, *nptr, strerror(errno));
  exit(EXIT_FAILURE);
 }

 return retv;
}


             reply	other threads:[~2006-01-10 21:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-10 21:42 J. [this message]
2006-01-10 22:34 ` strtod() and errno question James Stevenson
2006-01-11  3:01 ` Glynn Clements
2006-01-11 11:24   ` J.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0601102235490.1799-100000@hestia \
    --to=mailing-lists@xs4all.nl \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).