Re: some strange strtod behaviour, please help
On 7/7/06, O. Hartmann <[EMAIL PROTECTED]> wrote: Pietro Cerutti wrote: > On 7/7/06, O. Hartmann <[EMAIL PROTECTED]> wrote: >> Hello out here, >> sorry bothering you with some standard issues ... >> >> I ran into trouble with a routine from . > > No, from stdlib.h > > man strtod says: > SYNOPSIS > #include > > >> #include >> #include >> #include > > #include will solve your problems... > Yes, it does. Thanks ... I wonder why the compiler did not moan about a unknow call ... Because it could be an error or not, depending on what standard are you using. In C89 a function without a prototype is implicitly declared. This is not true if your're working in C99. Using cc with -Wimplicit as option will show you warnings about implicit function declarations.. Using cc with -Wall as option is usually good practice Thnaks a lot, oh -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: some strange strtod behaviour, please help
Pietro Cerutti wrote: On 7/7/06, O. Hartmann <[EMAIL PROTECTED]> wrote: Hello out here, sorry bothering you with some standard issues ... I ran into trouble with a routine from . No, from stdlib.h man strtod says: SYNOPSIS #include #include #include #include #include will solve your problems... Yes, it does. Thanks ... I wonder why the compiler did not moan about a unknow call ... Thnaks a lot, oh ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: some strange strtod behaviour, please help
On 7/7/06, O. Hartmann <[EMAIL PROTECTED]> wrote: Hello out here, sorry bothering you with some standard issues ... I ran into trouble with a routine from . No, from stdlib.h man strtod says: SYNOPSIS #include #include #include #include #include will solve your problems... -- Pietro Cerutti ICQ: 117293691 PGP: 0x9571F78E - ASCII Ribbon Campaign - against HTML e-mail and proprietary attachments www.asciiribbon.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
some strange strtod behaviour, please help
Hello out here, sorry bothering you with some standard issues ... I ran into trouble with a routine from . Trying to convert strings tokenized via strsep() to doubles lead me into unsolvable problems. This is an example piece of code taken from an exercise page (my own code looks similar, but this simple code reveals also the oddity of strtod or my oddity in thoughts): #include #include #include void main(void) { char *s,**p; float dx; int i; s = (char *) malloc(256 * sizeof(char)); strncpy(s,"1.234y",strlen("1.234y")); p = NULL; dx = strtod(s,p); i = 0, printf("String is: %s, Double is %#.G.\n",s,dx); printf("s[%i] is %c.\n",i,s[i]); } On my box (FreeBSD 6.1-STABLE, Intel i386, P4 3.0GHz, HTT enabled) at lab, compiling this with gcc (standard settings as taken from make.conf) results in weird behaviour, this also occurs on my home's box (also FreeBSD 6.1-STABLE, but AMD64). I also tried to give **p memory via malloc to see to what it points after strtod() has been called, but not success. The odd thing is, that I always given bad results like this: ./test String is: 1.234y, Double is -9.E+08. s[0] is 1. The row "printf("s[%i] is %c.\n",i,s[i]);" is only for some testing purposes to see what the initial portion of the string that is about to be converted may be. Ok, maybe I misunderstodd things. As I read the manpage, a string pointed to by *s containing digits, exponential sign and + or - is converted into a double returned by strtod(). If **p isn't the NULL pointer, it points to the first character couln't be a part of a number. In other words, I do not need to know what it is if s points to a legal number like in the example above. What is going wrong? Thanks in advance a lot, Oliver ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"