This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

cast a char[] = "" value(s)

hi Forum!

I have declared an char-array, for a simple Data stream buffer of bits:

char data[] = "101101010011111@".

And now just want cast this items to a integer-value. How can i do this in simplest way, without sum the bits bitwise via pointer?

cu
O. Swid

Parents
  • "Sorry, I'v just been looking for the easiest way to convert a sequence of character, like example "11101" in a integer-Value. I solved this by dint of pointer before, but was looking for a better way."

    There is no better way (to my knowledge) to convert a sequence of binary characters to an integer value than the ways that you've seen in your threads. That is, either explicitly convert while sequencing through your array (using a pointer or array index, and shift/add) or using strtol().

    Knowing that there is no better way, now you are well equipped to choose the method that suits you.

Reply
  • "Sorry, I'v just been looking for the easiest way to convert a sequence of character, like example "11101" in a integer-Value. I solved this by dint of pointer before, but was looking for a better way."

    There is no better way (to my knowledge) to convert a sequence of binary characters to an integer value than the ways that you've seen in your threads. That is, either explicitly convert while sequencing through your array (using a pointer or array index, and shift/add) or using strtol().

    Knowing that there is no better way, now you are well equipped to choose the method that suits you.

Children