Results 1 to 5 of 5

Thread: 2 C++ ??: 1) a Val() equivalent? 2) a conversion list?

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    2 C++ ??: 1) a Val() equivalent? 2) a conversion list?

    Hi all.
    I am just beginning my study of (Visual) C++ this week. I was re-writing a calculator I wrote in VB when I was just begiinning VB.

    So is there a C++ equivalent to Val() ?

    I found strtod(a,b) which seems to be the equivalent of
    vb's Cdbl(x) .

    Anyway, I can't get strtod to work. I just don't get it and the MSDN example doesn't make sense.
    So I have a string with a numerical value like "500"
    and I want to move that to a double like
    dblNumber = strtod(strNumber,????)
    and everything I put in the 2nd parameter creates errors.

    Okay, 2nd question, is there a place I can find a keyword (key function) conversion list for VB and C++? I think that would help the most.

    Thanks all.
    Wengang
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Try declaring the numerical variable as an integer

    Code:
    int SomeValue;
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    So is there a C++ equivalent to Val() ?
    probably not. Val does many other opererations besides converting unicode strings to variant numeric datatypes
    Okay, 2nd question, is there a place I can find a keyword (key function) conversion list for VB and C++? I think that would help the most.
    many vb functions doesn't exist in c++, however there are libraries with algoritms that perform more specific actions.

    i think you have to pass a double pointer in ???? place, if you declare a double x, you pass &x
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    ad 1:
    The second param is of type char **ppEndPtr. This means it's a pointer to a pointer to a character. This works the following way:
    Pass the string "347.28aiw" to strtod. The function will extract 347.28 and stop at the 'a', since it is not a number. The function will the set the *ppEndPtr to the 'a', so you know afterwards until where the function did read the string. You can either pass NULL or like this:
    char* str = "279.18aiw";
    char* pEndChar;
    double val = strtod(str, &pEndChar);

    ad 2:
    You can always ask us if you need a funciton equivalent.

    All the buzzt
    CornedBee

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Well yes there are some VB functions that don't exist in C++ but they call all be improvised.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width