using namespace std;
int main(){
  vector<string> names;
  string const endinput("END");
  cout << "type '" << endinput << "' when there are no more names.\n\n";
  for( int finished(0); finished != 1; ){
     cout << "type in the next name; ";
     string fullname;
     getline( cin, fullname );
     if( endinput == fullname )
            finished = 1;
     else
            names.push_back( fullname ) ;
   }
   sort( names.begin(), names.end());
   ofstresam outfile("name.txt");
   for( int i(0); i != names.size(); ++i ){
      cout << names[i] << '\n';
      outfile << names[i] << '\n';
   }
}
实在看不懂你的错误是什么意思
我就改了一下
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
using namespace std;
int main(){
  vector<string> names;
  const string  endinput("END");
  cout << "type '" << endinput << "' when there are no more names.\n\n";
  for( int finished(0); finished != 1; ){
     cout << "type in the next name; ";
     string fullname;
     getline( cin, fullname );
     if( endinput == fullname )
            finished = 1;
     else
            names.push_back( fullname ) ;
   }
   sort( names.begin(), names.end());
   ofstream outfile("name.txt");
   for( int i(0); i != names.size(); ++i ){
      cout << names[i] << '\n';
      outfile << names[i] << '\n';
   }
}
这里面可能还有问题,不知道改的对不对