Use the size()
or length()
members to get the length of a string, and data()
to get a pointer to the data:
sendto(sockfd, it->data(), it->size(), ...);
If you're stuck with a pre-2011 implementation, then data()
won't exist, so use c_str()
instead.