<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.18.3">
</HEAD>
<BODY>
<PRE>
Buenas noches:

Estaba practicando cuando esto me ha dado un error que no he sabido solucionar:

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
        ofstream f2;
        f2.open("fichero.txt", ofstream::out); 


        char nombre[100];  //Cadena de carácteres. 
        cout<<"Escriba su nombre y pulse Intro: ";
        cin >>nombre;  //Lee lo escrito
        f2 << nombre;  //Lo guarda en fichero.txt

                char apellido[100];
                cout<<"Escriba su apellido y pulse Intro: ";
                cin>>apellido;  //Lee el apellido escrito.
                f2<<" ";  //Crea un espacio entre nombre y apellido.
                f2<<apellido;  //Escribe el apellido en fichero.txt

        f2.close("fichero.txt");
        f2.open("fichero.txt", ofstream::in); 
        f2<<apellido;
}

¿Qué estoy haciendo mal?

Un saludo.

Rubén
</PRE>
</BODY>
</HTML>