Devo aggiungere una lista di cognomi da due file in un terzo ordinandoli alfabeticamente ma non mi riesce!
Questo è quello che ho fatto: 
//prova di gestione file e fusione
#include <iostream>
#include <fstream>
#include <string>
#define maxcar 50
using namespace std;
typedef char tipofile[maxcar];
tipofile file1,file2,file3;
int main()
{
	cout<<"\nInserire il nome del primo   file : ";
	cin.getline(file1,50,'\n');
	cout<<"\nInserire il nome del secondo file : ";
	cin.getline(file2,50,'\n');
	cout<<"\nInserire il nome del terzo   file : ";
	cin.getline(file3,50,'\n');
	fstream f1,f2,f3;
	string buffer1,buffer2;
	f1.open(file1, ios::in);
	f2.open(file2, ios::in);
	f3.open(file3, ios::out);
	if(!f1 && !f2 && !f3)
	{
		cout<<"Errore nell'apertura dei file!";
		return -1;
	}
	while(f1.good() && f2.good())
	{
		getline(f1,buffer1);
		getline(f2,buffer2);
		if(buffer1<buffer2)
		{
			f3<<buffer1<<endl;
			getline(f1,buffer1);
		}
		else
		{
			f3<<buffer2<<endl;
			getline(f2,buffer2);
		}
	}
	while(f1.good())
	{
		f3<<buffer1<<endl;
		getline(f1,buffer1);	
	}
	while(f2.good())
	{
		f3<<buffer2<<endl;
		getline(f2,buffer2);
	}
	
	f1.close();
	f2.close();
	f3.close();
	cout<<"\nscrittura avvenuta.";
	return 0;
}