Sep 25, 2012 at 2:26pm UTC
Ok, I understand that, but the "10101010" is stored as a string, not a char array. What's the syntax to convert a string to a char array so I can use the above?
Sep 25, 2012 at 2:33pm UTC
1 2 3 4
#include <algorithm>
std::transform( stringName.begin(), stringName.end(), array,
[]( char c ) -> int { return ( c - '\0' ); } );
Last edited on Sep 25, 2012 at 2:37pm UTC
Sep 25, 2012 at 2:40pm UTC
error C2039: 'transfer' : is not a member of 'std'
is the error I get when I try to use the above....
Sep 25, 2012 at 2:45pm UTC
a "string" is just a specialized character array with a null terminator. (with the exception of std::string)
Last edited on Sep 25, 2012 at 2:45pm UTC
Sep 25, 2012 at 3:05pm UTC
@enosmac
error C2039: 'transfer' : is not a member of 'std'
is the error I get when I try to use the above....
There was a typo. Instead of transfer shall be transform.
@enosmac
Not sure why the -48 works
48 is ASCII code of '0'. It is better to use '0' instead of 48.
Last edited on Sep 25, 2012 at 3:07pm UTC