Look at this pieces of code:
cout<<"Nombre del paciente: ";
scanf("%s", &nombre);
you put inside nombre
the name of a person. Then you do this:
strcat(nombre,".dat");
so you append .dat
to nombre
what effectively becomes: nombre.dat
and uses that to write into your archive
By the way, note this much more an 'C' question than an 'C++' question, once you are using, in this majority, 'C' functions.
To solve this, just create a new variable and populates it, like:
char filename[100];
strcpy(filename, nombre);
strcat(filename, ".dat");