Professional Web Applications Themes

Do we have any class converting binary string to integer? - UNIX Programming

Hi, string s = "1001"; we I convert s to an integer? thanks....

  1. #1

    Default Do we have any class converting binary string to integer?

    Hi,

    string s = "1001";

    we I convert s to an integer? thanks.


    Daqian Guest

  2. #2

    Default sorry, wrong grp..

    sorry


    Daqian Guest

  3. #3

    Default Re: Do we have any class converting binary string to integer?

    "Daqian Yang" <ca> wrote in message news:<bvbb56$1c4q$acadiau.ca>... 

    If I got your question the right way, one possibility is the following
    (assuming s is a STL string) :

    int i = atoi(s.c_str());
    Eric Guest

  4. #4

    Default Re: Do we have any class converting binary string to integer?

    Eric Entressangle <fr> wrote: [/ref]
     
     

    Since the OP seems to have a string representing a number in binary,
    not decimal, strtol() would look like a better choice because it
    allows to specify the base. Moreover, it also allows error checking
    and thus is usually considered to be preferable over atoi().

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ fu-berlin.de
    \__________________________ http://www.physik.fu-berlin.de/~toerring
    Jens.Toerring@physik.fu-berlin.de Guest

Similar Threads

  1. string to integer
    By Mark Fenbers in forum Macromedia Flash Data Integration
    Replies: 10
    Last Post: May 23rd, 08:08 AM
  2. ASP integer date/time converting problems
    By Ralph Hodenius [MS] in forum ASP Database
    Replies: 0
    Last Post: January 8th, 02:01 PM
  3. Integer to Hex string?
    By Steve in forum Mac Programming
    Replies: 6
    Last Post: December 7th, 07:24 AM
  4. converting Raw integer color values to RGB?
    By paul in forum Macromedia Director Lingo
    Replies: 3
    Last Post: August 28th, 05:11 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139