You doubt. Why can not I create the file?

0
int main()
{

    struct cliente
{
       int documento;
       char nombre[20];
       char apellido[20];
       char telefono[10];
       int ocupacion;
       int sueldo;
};
    char opc;

    entrada.open("datoscliente.txt",ios::out|ios::app);
    if (entrada.fail())
    {
      cout<< "ERROR AL ABRIR EL ARCHIVO"<<endl;
     }
       else
      {
       do
         {
                      cout<<"******DATOS DE CLIENTE*******"<<endl;
                      cout<<endl;
                      cout<<"DOCUMENTO: ";
                      cin>> documeto;
                      cout<<"NOMBRE:  ";
                      cin>>nombre;
                      cout<<"APELLIDOS:  ";
                      cin>>apellidos;
                      cout<<"SUELDO:  ";
                      cin>>sueldo;
                      entrada<<codigo<<" "<<nombre<<" "<<apellidos<<" "<<sueldo<<endl;
                      cout<<endl;
                      cout<<"desea continuar ingresando datos si 1/ no 2"<<endl;
                      cin>>opc;
                      opc=toupper(opc);
         }while (opc == 2);
     }
   entrada.close();               
  system ("pausa");
return (0);                     
}
    
asked by Pedro Antonio Obregon Alomia 29.11.2016 в 16:46
source

1 answer

0

Notice that you are sending out:

entrada<<codigo<<" "<<nombre<<" "<<apellidos<<" "<<sueldo<<endl;

and code does not exist .. but if there is a document ... sure your problem is there.

    
answered by 29.11.2016 в 17:05