Bienvenido: ( Identificarse | Registrarse )      
Foros de Trucos Windows
 
Closed TopicStart new topicStart Poll

Outline · [ Estándar ] · Lineal+

> Ayuda en C++

checlops
post May 29 2008, 05:07 AM
Publicado: #1


Newbie
*

Grupo: Members
Mensajes: 1
Registrado: 29-May 08
Miembro nº: 232.156



Tengo un problema es que por mas que cambio el codigo de la agenda no logro que guarde los datos ingresados en Txt o en dat , osea necesito que guarde todos los datos que se le ingresan pero en mi camino me he encontrado con errores que nunca he visto estoy usando turbo c ojala puedan ayudarme, aqui esta el codigo

CODE

#include <iostream.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>



void menu(void);

void agregar(void);
void cambiar(void);
void mostrar(void);
void borrar(void);


class persona {
public:
persona();
void modificar(void);
void listar(void);
private:
char nombre[32];
char appaterno[50];
char apmaterno[50];
char domicilio[30];
char telefono[15];
int id;
};


persona *p[10];

int total;
char opta;



persona::persona() {
cout << "Nombre :\n "; cin.getline(nombre, sizeof(nombre));
cout << "Apellido Paterno :\n "; cin.getline(appaterno, sizeof(appaterno));
cout << "Apellido Materno :\n "; cin.getline(apmaterno, sizeof(apmaterno));
cout << "Domicilio :\n "; cin.getline(domicilio,
sizeof(domicilio));
cout << "Telefono :\n "; cin.getline(telefono,
sizeof(telefono));
cout << "ID :\n\n "; cin >> id; cin.get();
{
cout << "GUARDANDO DATOS...\n\n" << endl;
getch();
cout << "LOS DATOS YA FUERON GUARDADOS..." << endl;
getch();

}
cout << "-----------------------------------\n" << endl;
};


void persona::modificar(void)
{ char opcion;
cout<< "Deseas modificar el domicilio (S/N) : ";
do { opcion = cin.get();
opcion = toupper(opcion);
} while ((opcion !='S') && (opcion !='N'));
if (opcion == 'S') { cout << "Domicilio :\n\n";
{
cout << "BUSCANDO DATO..." << endl;
getch();
} cin.get();
cin.getline(domicilio,sizeof(domicilio));}
cout<< "Deseas modificar el telefono (S/N) : ";
do { cin.get(opcion);
opcion = toupper(opcion);
} while ((opcion !='S') && (opcion !='N'));
if (opcion == 'S')
{
cout << "BUSCANDO DATO..." << endl;
getch();
}
{ cout << "Telefono :\n "; cin.get();
cin.getline(telefono, sizeof(telefono));}
}
                        void persona::listar(void)
{
cout << "**************************\n\n" << endl;
cout << "Nombre : " << nombre << endl;
cout << "Domicilio : " << domicilio << endl;
cout << "Telefono : " << telefono << endl;
cout << "ID : " << id << endl;
};

void menu()
{
textcolor(7);
clrscr();
gotoxy(38,10); textcolor(7); cprintf("AGENDA!!!");
gotoxy(34,11); textcolor(1); cprintf("1.- Agregar Contacto");
gotoxy(34,12); textcolor(1); cprintf("2.- Modificar Contacto");
gotoxy(34,13); textcolor(1); cprintf("3.- Borrar Contacto");
gotoxy(34,14); textcolor(1); cprintf("4.- Mostrar el contenido");
gotoxy(34,15); textcolor(1); cprintf("5.- SALIR");
gotoxy(36,16); textcolor(4); cprintf("Opcion >>> ");
do
opta=getch();
while ((opta < '1') || (opta > '5'));
switch (opta) {
case '1': agregar();break;
case '2': cambiar();break;
case '3': borrar();break;
case '4': mostrar();break;
case '5': exit (1);break;
}
}

                      void agregar(void)
{ if (total==10) { gotoxy(20,23);
cout << "No hay espacio disponible" << endl;
delay(1000);}
else { clrscr();
p[total] = new persona;
total++;
}
}

void cambiar(void)


{ int cual; char opcion;
if (total==0) { gotoxy(2,23);
cout << "No existen registros" << endl;
delay(2000);}
else { clrscr();
cout << "Existen"<< total << " Registros, Cual deseas modificar ???\n ";
cin >> cual; cin.get();
p[cual-1]->listar();
cout<< "\nDeseas cambiar el registro (S/N)?:\n";
do { opcion = cin.get(); cin.get();
opcion = toupper(opcion);
}while ((opcion !='S') && (opcion !='N'));
if (opcion == 'S')
{
cout << "EN PROCESO...\n\n" << endl;
getch();
}
p[cual-1]->modificar();
}
}


  void borrar(void)

{
int cual;

if (total==0) { gotoxy(2,23);
cout << "No existen registros" << endl;
delay(2000);
}
else { clrscr();
cout << "Existen"<< total << " Registros, Cual quiere borrar??? \n";
cin >> cual; cin.get();
delete p[cual-1];
p[cual-1] = p[total-1];
total--;
}
cout << "BORRANDO...\n\n\n" << endl;
getch();
cout << "Operacion EXITOSA" << endl;
getch();
}

                                            // manda llamar el metodo listar
 void mostrar(void)

{
int cual; int j;
if (total==0) { gotoxy(2,23);
cout << "No existen registros" << endl;
delay(2000);}
else {
clrscr();
cout << "Existen"<< total << " Registros, Cual  se desea ver??? \n";
cin >> cual; cin.get();
{
cout << "BUSCANDO DATOS DEL CONTACTO...\n\n" << endl;
getch();
}
{
cout << "PROCESO EXISTOSO...\n\n" << endl;
getch();
}
if(cual <=total) {    p[cual-1]->listar();
delay(2000);
}
else { for(j=0; j<total;j++) p[j]->listar();
delay(3000);
}
getch();
}
}

void main(void)
{ clrscr();
total = 0;
do
menu();
while(opta != '6');
};








GRACIAS


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
PC_MAC
post Jun 2 2008, 07:26 PM
Publicado: #2


Miembro Elite
****

Grupo: Members
Mensajes: 119
Registrado: 11-November 07
Miembro nº: 217.125



Busca en internet el manejo de ficheros en Google seguro sale. Te doy una idea: tienes que crear una variable FILE y una variable de escritura.

Saludos


User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
Closed TopicTopic OptionsStart new topic

Collapse

> Topicos similares

ayuda rgente plissss cuxo99 19 2 Hoy, 01:47 AM
By: cuxo99
ayuda con mi conexion a internet SiverNet 71 2 Ayer, 11:37 PM
By: SiverNet
Ayuda con Slax Rommel_A 62 6 Ayer, 09:40 PM
By: Rommel_A
Daños a La Memoria Ram, Ayuda Porfavor... Elena_Russo 61 3 Ayer, 09:05 PM
By: Elena_Russo

Google
Web www.trucoswindows.net