Answer the question
In order to leave comments, you need to log in
C++ duplicate removal, why doesn't it work?
Help me understand why it works in visual studio, but not in qt
I'm learning don't throw poop
void Wid::test() {
vector<string> stp;
stp.push_back(text->toPlainText().toStdString());
sort(stp.begin(),stp.end());
stp.erase(unique(stp.begin(),stp.end()),stp.end());
ofstream filesave(pp);
copy(stp.begin(),stp.end(), ostream_iterator<string>(filesave,"\n"));
}
Answer the question
In order to leave comments, you need to log in
void Wid::test() {
vector<string> stp;
stp.push_back(text->toPlainText().toStdString());
// В stp одна штука
sort(stp.begin(),stp.end());
// Ну что ей будет, этой штуке?
stp.erase(unique(stp.begin(),stp.end()),stp.end());
// unique даст end; поведение vector при этом не определено.
ofstream filesave(pp);
copy(stp.begin(),stp.end(), ostream_iterator<string>(filesave,"\n"));
}
As Mercury13 correctly noted, you have one element in your vector - the entire contents of the QPlainTextEdit, along with line breaks, etc.
To work the way you want, you need to take this content, split it into lines, stuff it into a vector, and then work with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question