i found this code online and im trying to get it to overwrite
the original file instead of printing to screen but i have to admit
its too advanced for me can anyone help please

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iterator>

using namespace std;

int main()
{
  vector <string> array;

  std::ostream_iterator< string > output ( cout, "\n" );

  ifstream read ( "letters3.txt" );
  string line;
  while ( getline ( read, line, '\n' ) )
  {
        array.push_back ( line );    
  }
  read.close(); 
  sort ( array.begin(), array.end() ); 

  std::vector< string >::iterator endLocation;
  endLocation = std::unique ( array.begin(), array.end() );

    std::copy ( array.begin(), endLocation, output ); 
  
   
  cin.get();
  return 0;
}

OP want to write back sorted text content into same file.
>i found this code online and im trying...
--Try to learn stream classes.

This article has been dead for over six months. Start a new discussion instead.