qazmlp wrote:
How can string be converted into a byte array in C++ ?
Can I used std::bitset<> to do it ?
A string IS an array of 'string::value_type' underneath.
Why do you need to convert it ?
Here is an example - you can use the method
"data()" and return a const char *
Or, why not just use iterators as arrays ? (second example).
#include <iostream>
#include <string>
int main()
{
std::string foo( "ABC" );
//examp 1
const char * array = foo.data();
array[0] + array[2];
//examp 2
std::string::iterator iter_array = foo.begin();
iter_array[ 2 ] = 'x';
std::cout << foo << '\n';
}