How to copy a std::string to unsigned char array?
Here's one way:
#include <algorithm>
#include <iostream>
auto main() -> int
{
unsigned char trap[256];
std::string sample = ".1.3.6.1.4";
std::copy( sample.begin(), sample.end(), trap );
trap[sample.length()] = 0;
std::cout << trap << std::endl;
}
It can be a good idea to additionally check whether the buffer is sufficiently large.