how to transform an aray of char in to a big number

This is a discussion on how to transform an aray of char in to a big number within the C Programming forums, part of the General Programming Boards category; Suppose i get an array of chars "(1110,999)(10,10)" how extract the numbers which are in the coordinates 1110 999 10 ...

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    how to transform an aray of char in to a big number

    Suppose i get an array of chars
    "(1110,999)(10,10)"
    how extract the numbers which are in the coordinates
    1110
    999
    10

    the -'0' thing works only for a single digit numbers
    ??

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    395
    you have to extract 'manually' the substrings corresponding to each number then you apply strtol() (this is one solution) to each one of them, e.g. strtol("1110",0,10) returns you (long)1110. For the 'how extract the number', I let you think a bit (you can check strtok() for instance).

    PS: you can use the -'0' thing as you say, if you write your own str to int function (as you work on single digits)
    Last edited by root4; 01-03-2009 at 06:44 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  2. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  4. Replies: 7
    Last Post: 06-16-2006, 10:23 PM
  5. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM

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