The idea is to send the size of the string first and then allocate the storage on the reciever. Here is an example with broadcast.
string s = "before";
int size = 0;
if (myRank == 0)
{
s = "after";
size = s.size();
}
BroadCast(&size,1);
if (myRank != 0) s.resize(size);
BroadCast(s.data(),size);
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>