Thread: strtod

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490

    strtod

    double strtod(char*,char**)
    i need a replacement, is there a free one? my program cannot use stdlib.h, and the target enviroment is very picky about "standard" functions.
    could atof be used to replace this?

  2. #2
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    What program do you use? If you can't use the stdlib.h file, then you will not be able to use atof() either. Can you use the string.h file? As I remember, the strtod() function is defined in that header.

    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    i'm writing a graphing calculator for a pda(vtech helio) which uses weird libs. i have the parser for the equation from snippets.org, but it needs strtod. my compiler is gcc, although i don't know what version. the compiler, linker, etc.. are all dos programs. I know i definitely cannot use stdlib.h, but i'm not sure about string.h. i doubt it, though.

  4. #4
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    Can't you use "sscanf" from stdio.h?

    alex

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    can't use stdio.h either.

  6. #6
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    why cant you use stdio.h ?
    Monday - what a way to spend a seventh of your life

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Well a really simple - no error checking - atoi would look like this

    Code:
    char buff[] = "1234";  // for example
    int result = 0;
    int i;
    for ( i = 0 ; buff[i] != '\0' ; i++ ) {
        result = result * 10 + buff[i] - '0';
    }

  8. #8
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    the sdk for this pda doesn't include most normal functions. check out the message board at pdabuzz.com -> other platforms -> vtech -> vtech software development for more info. it also sucks at float calculations, although double works.

    would i be correct if i said that:
    1)strtod(char* sz1,char** psz2) takes the beginning characters of the string sz1 and stopped when it wasn't a number anymore, where that pointer would be passed back through psz2?
    2) would i be correct in assuming that the psz2 is not needed most of the time? from eval.c:
    Code:
    if (0.0 == (arg = strtod(str, &endptr)) && .....
    endptr appears only twice in eval.c: when it's defined and here. i'm thinking if it's not needed, something like atof could be used instead.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with strtod
    By robert777 in forum C Programming
    Replies: 11
    Last Post: 11-03-2008, 12:49 PM
  2. How does strtod manage to parse?
    By seedpress in forum C Programming
    Replies: 4
    Last Post: 03-23-2005, 06:03 PM
  3. More strtod troubles
    By Bajanine in forum Windows Programming
    Replies: 2
    Last Post: 03-09-2003, 01:23 PM
  4. Help with strtod and fgets..
    By Gugge in forum C Programming
    Replies: 2
    Last Post: 05-15-2002, 02:21 PM
  5. replacement to strtod
    By ygfperson in forum C Programming
    Replies: 1
    Last Post: 01-13-2002, 08:46 PM