Hi I have a question on ofstream!!
I am trying to write program that takes words from a text file and sort then in increasing order by using min priority queue.!!
I am having trouble on outputting sorted sting data.
1 2 3 4 5 6 7
outfile.open("result.txt");
string temp;
for (int i = 0; i<50; ++i){
temp = pq1.top() + " ";
outfile<<temp;
}
outfile.close();
As you can see I assigned the element from the min priority queue named pq1 to the string variable temp. And then try to write into the txt file named "result.txt". The txt file "result.txt" have weird text instead the words separated by space. Does anyone know why this is happening??