Strings

This is a discussion on Strings within the C Programming forums, part of the General Programming Boards category; If have a Sring char *t="39"; how can I convert it to a number ? so I can add subtract ...

  1. #1
    Unregistered
    Guest

    Strings

    If have a Sring char *t="39";
    how can I convert it to a number ?
    so I can add subtract from it can I use cast here?

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    You cannot cast it. There is a function atoi() which you could use. Or else write your own function. Take a digit, determine it's place and multiply it with 10^place. And add all the results. Like:

    3 * 10^1 + 9 * 10^0 = 39

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 07:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 03:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 12:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21