Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Converting from char to int

    is there a function or something that converts a character number value like '42' to a decimal 42...

    thanks for the help...
    Lippy

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    England
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeh, toInt()

  • #3
    New Coder
    Join Date
    Dec 2004
    Location
    Colombo, Sri Lanka | S.E. Asia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In what language is this?

    You can also type cast, just to let you know.


    Example:
    Code:
    myString = (int) myString;
    <@Bane>Go on baby, be kinky and talk to me in PHP.

    root@koobi:~ # I recommend all my clients to MBSHost
    root@koobi:~ # PHP Scripts I'm working on
    root@koobi:~ # I have a blog now?

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Location
    England
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Koobi
    In what language is this?

    You can also type cast, just to let you know.


    Example:
    Code:
    myString = (int) myString;
    That depends on what language as well. In Java, if you do that, it wouldn't work as myString is most probably of type String, so casting it to an int and shoving it back in a variable with a data type of String wouldn't work.

  • #5
    New Coder
    Join Date
    Dec 2004
    Location
    Colombo, Sri Lanka | S.E. Asia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by KeZZeR
    That depends on what language as well. In Java, if you do that, it wouldn't work as myString is most probably of type String, so casting it to an int and shoving it back in a variable with a data type of String wouldn't work.

    Yep, thanks for pointing that out
    I neglected to mention that the method I posted would work in C++
    <@Bane>Go on baby, be kinky and talk to me in PHP.

    root@koobi:~ # I recommend all my clients to MBSHost
    root@koobi:~ # PHP Scripts I'm working on
    root@koobi:~ # I have a blog now?

  • #6
    New Coder
    Join Date
    Nov 2004
    Location
    Netherlands
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In C you can use the atoi() function, or create your own.

  • #7
    New Coder
    Join Date
    Nov 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, that atoi function works great...


  •  

    Posting Permissions

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