delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/01/03/17:40:46

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Re: BUG: strtod() completely fails under cygwin-b20
3 Jan 1999 17:40:46 -0800 :
Message-ID: <199901031657.KAA00964.cygnus.gnu-win32@modi.xraylith.wisc.edu>
References: <368F41FF DOT A97718DD AT mindless DOT com>
To: Dobes Vandermeer <dobes AT mindless DOT com>
Cc: gnu-win32 AT cygnus DOT com

Dobes Vandermeer <dobes AT mindless DOT com> writes:
> 
> Here is my program:
> 
> int main()
> {
>   double val = strtod("3.123", 0);
>   printf("TEST: %g %g\n", 3.123, val);
>   return 0;
> }

Basic rule of C/C++ programming -- include the appropriate header so that
the prototypes are available. In your case, including stdlib.h should fix
it.

  #include <stdlib.h>
  #include <stdio.h>

  int main()
  {
    double val = strtod("3.123", 0);
    printf("TEST: %g %g\n", 3.123, val);
    return 0;
  }

> The results I WANTED would have 3.123 both times, and this is the
> behavior documented.
> 
> This same behavior is exhibited by atof()... This is a bug, I think.

Yes, it's a bug in your code.

You should *really* pay more attention to the compiler when it complains
about not finding the prototypes for strtod, printf etc; that should've
given you a clue as to what is wrong.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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