it doesn't broadCast string properly , can any one correct my errorCode:string Image_name; cout<<"enter image name"<<endl; cin>>Image_name; MPI_Bcast(&image_name2, 100*sizeof(char), MPI_CHAR, MasterID, MPI_COMM_WORLD);
it doesn't broadCast string properly , can any one correct my errorCode:string Image_name; cout<<"enter image name"<<endl; cin>>Image_name; MPI_Bcast(&image_name2, 100*sizeof(char), MPI_CHAR, MasterID, MPI_COMM_WORLD);
Last edited by Salem; 06-01-2011 at 01:53 PM. Reason: Try using correct tags
Is there supposed to be a relationship between Image_name and image_name2? Any reason for 100?
image_name2="D:\\ImgDB\\" +Image_name;
100*sizeof(char) -------> I think it is the message size
Why do you think that 100*sizeof(char) is the message size? Wouldn't it depend on the length of image_name?
Also if image_name2 is defined as a string, you are going to have to convert it to a char array in order to broadcast it.
orCode:MPI_Bcast(image_name2.c_str(), image_name2.size(), MPI_CHAR, MasterID, MPI_COMM_WORLD);
if the string is supposed to be null terminated.Code:MPI_Bcast(image_name2.c_str(), image_name2.size() + 1, MPI_CHAR, MasterID, MPI_COMM_WORLD);