I have a vector of 8 bit unsigned char
s & a vector of 16 bit unsigned short
s
std::vector<unsigned char> eight_bit_array;
std::vector<unsigned short> sixteen_bit_array;
sixteen_bit_array.resize(x_number_of_samples);
eight_bit_array.resize((x_number_of_samples)*2);
I have populated some data into the sixteen_bit_array
. Thats cool. I want to know if it is possible to typecast & store the sixteen_bit_array
& into the eight_bit_array
& How ?
I have a method which returns the eight_bit_array
by returning a pointer to unsigned char
like so:
// A legacy method which returns the char array
unsigned char *GetDataSample(std::size_t sample_number) {
return &eight_bit_array[sample_number];
}
So I want to typecast & store the sixteen_bit_array
into the eight_bit_array
so that I can return 16 bit unsigned ints
without having to change the return type of my legacy method from unsigned char *
to unsigned short *
Please suggest how to do this.