I have unsigned char array. I want to print all array value by using cout. How can I do that?
rtc::ZeroOnFreeBuffer<unsigned char> charArray(key_len * 2 + salt_len * 2);
cout<< charArray; --> ?
I have unsigned char array. I want to print all array value by using cout. How can I do that?
rtc::ZeroOnFreeBuffer<unsigned char> charArray(key_len * 2 + salt_len * 2);
cout<< charArray; --> ?
for (auto&& c : charArray){
cout << c;
}
is probably the simplest way, assuming you want the actual characters rather than the numbers (if you want numbers then replace auto&&
with int
), and your container is iterable.
Assuming you're using the ZeroOnFreeBuffer from WebRTC, you can use a for loop, and obtain the current size of the buffer:
size_t bufSize = charArray.size()
for (int i = 0; i < bufSize; i++){
cout << charArray[i];
}
In any case, how you access the data and iterate over it depends upon the nature of ZeroOnFreeBuffer
. Look at the documentation for that object, and it will give you methods to access the data, find the size of the buffer, and perhaps even how to obtain iterators for such things as range-for loops.