#include
#include
#include
#include
using namespace std;
int main() {
ifstream in_file ("d:\\test.txt");
string word;
vectortext;
while (in_file>>word)
text.push_back(word);
in_file.close();
int ix;
for (ix=0;ixcout << text[ix] << " ";
sort(text.begin(), text.end());
cout << endl;
for (ix=0;ixcout << text[ix] << " ";
return 0;
}
run result:
we were her pride of ten she named us.
her named of pride she ten us. we were
Process returned 0 (0x0) execution time : 0.004 s
Press any key to continue.
你的问题是什么?
因为你的程序没有向console中做输出,输出结果是到文件,你查看运行后的文件就可以知道对不对了。
另外,你程序中没有对文件进行关闭操作。
在读的时候,打印出来看看有没有读到 。。。。。。。。。。。