I was trying to output a not null terminated char array to a file.
Actual thing is, I am receiving packets and then printing their fields.
Now as these field
I see mainly two solutions.
In case of ASCII data:
memset(dest,0,destlength); bytescopied = strncpy(dest, src, maxbytes);
then You'll always have clear null-terminated string in buffor.
Second in case of ASCII data:
std::string yourASCII(src,maxbytes); yourASCII.c_str() // would be null terminated.