Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/07/2010, 11:26
keiko007
 
Fecha de Ingreso: julio-2010
Mensajes: 16
Antigüedad: 14 años, 2 meses
Puntos: 0
Exclamación Ayuda con esto..

necesito ayuda para agregar una funcion para imprimir por impresora un archivo..
creo que mi cod tiene algunos errores...si lo arreglan mejor aun agreguen las bibliotecas..con me entraron en el mens


int selecc;

void insertar(void);
void lista (void);
void mostrar (void);
void borrar (void);
void guardar (void);
void recuperar (void);
void memo (void);
void visualizar ();
void cliente_menu();
void menu();
void opcion();

void memoria(void);

struct cliente *pantalla ();
struct cliente *buscar ();



struct pelicula *pantalla1 ();
struct pelicula *buscar1 ();

struct pelicula
{
char cod_pelicula[10];
char nombre_pelicula[20];
char genero[20];
char precio[10];
char alquilada[1];

struct pelicula *siguiente;
};

struct pelicula *uno, *novo, *indi;


struct cliente
{
char nombre [30];
char apellido [30];
char ci[15];
char telefono[10];
char domicilio[20];
char cd1[10];
char cd2[10];
char cd3[10];
char cd4[10];
char cd5[10];
char retiro[10];
char entrega[10];
char costo[10];


struct cliente *sigte;
};

struct cliente *primero, *nuevo, *indice;


void memo(void)
{
nuevo= (struct cliente *) malloc (sizeof (struct cliente));

if (nuevo == NULL)
{
printf ("\nEspacio insuficiente de memoria");
return;
}
if (primero == (struct cliente *) NULL)
primero = indice = nuevo;
else
{
indice = primero;

while (indice -> sigte!= (struct cliente *)NULL)
indice = indice ->sigte;
indice -> sigte =nuevo;
indice =nuevo;
}
}

main()
{
menu();
}

void menu ()
{
system("cls");
printf("\n\t -------MENU PRINCIPAL--------\n\n");
printf("\n\t 1.--- PELICULAS\n\n");
printf("\n\t 2.--- CLIENTES\n\n");
printf("\n\t 3.--- SALIR\n");
printf("\n\t -----------------------------\n");

fflush(stdin);
selecc=getch();
opcion();
}


void opcion()
{

switch(selecc)
{
case'1': system("cls");pelicula_menu();//crear despues
break;
case'2': system("cls");cliente_menu();
break;
case'3':exit(0);
}
}

void cliente_menu()
{
primero =(struct cliente *) NULL ;
while (TRUE)
{

puts("\n\t\t\t CONTROL DE CLIENTES");
puts("\t\t\tOJOS DORMIDOS DVD CLUB");
puts("\t\t\t**********************");
puts ("\n\t\t\t MENU");
puts ("\t\t ------------------------");
puts ("\t\t 1.------ DATOS DEL CLIENTE.");
puts ("\t\t 2.------ LISTAR TODOS LOS CLIENTES.");
puts ("\t\t 3.------ MOSTRAR DATOS POR CLIENTE.");
puts ("\t\t 4.------ BORRAR CLIENTE.");
puts ("\t\t 5.------ GUARDAR.");
puts ("\t\t 6.------ RECUPERAR.");
puts ("\t\t 7.------ MENU PRINCIPAL.");

switch (toupper (getche()))
{
case '1': insertar(); break;
case '2': lista(); break;
case '3': mostrar(); break;
case '4': borrar(); break;
case '5': guardar(); break;
case '6': recuperar(); break;
case '7': menu();
}
}
}


void insertar(void)
{

memo();
system("cls");

printf("\n\t\t NOMBRES: ");
gets(indice ->nombre);

printf ("\n\t\t APELLIDOS: ");
gets (indice -> apellido);

printf ("\n\t\t C_I Nro.: ");
gets (indice -> ci);

printf ("\n\t\t DOMICILIO: ");
gets (indice -> domicilio);

printf ("\n\t\t CD1<000>: ");
gets (indice -> cd1);

printf ("\n\t\t CD2<000>: ");
gets (indice -> cd2);

printf ("\n\t\t CD3<000>: ");
gets (indice -> cd3);

printf ("\n\t\t CD4<000>: ");
gets (indice -> cd4);

printf ("\n\t\t CD5<000>: ");
gets (indice -> cd5);


printf ("\n\t\t FECHA DE RETIRO <dd/mm/aa>: ");
gets (indice -> retiro);

printf ("\n\t\t FECHA DE ENTREGA<dd/mm/aa>: ");
gets (indice -> entrega);

printf ("\n\t\t COSTO: ");
gets (indice -> costo);

indice -> sigte = (struct cliente *) NULL;
}


void lista(void)
{
system("cls");
if (primero == (struct cliente *) NULL)
{
puts("\n Lista Vacia...");
return;
}
indice = primero;
do
{
visualizar (indice);
indice = indice->sigte;
}while (indice != (struct cliente *) NULL);
}


void visualizar(struct cliente *ver)
{
system("cls");
printf("\n\t Nombre: %s", ver -> nombre);
printf("\n\t Apellido: %s", ver -> apellido);
printf("\n\t C_I Nro.: %s", ver -> ci);
printf("\n\t Domicilio: %s", ver -> domicilio);
printf("\n\t CD1: %s", ver -> cd1);
printf("\n\t CD2: %s", ver -> cd2);
printf("\n\t CD3: %s", ver -> cd3);
printf("\n\t CD4: %s", ver -> cd4);
printf("\n\t CD5: %s", ver -> cd5);
printf("\n\t Fecha de retiro: %s", ver -> retiro);
printf("\n\t Fecha de entrega: %s", ver -> entrega);
printf("\n\t Costo: %s\n", ver -> costo);
printf("\n---------------------------------------------------\n\n");
}

void mostrar (void)
{

char inbuf [30];

system("cls");
printf("\nEscriba el NOMBRE a buscar: ");
while (kbhit());
gets (inbuf);
pantalla (inbuf);
}

void borrar (void)
{
struct cliente *borra;
char inbuf[30];

system("cls");
printf("\nEscriba el NOMBRE a borrar: ");

while (kbhit());
gets(inbuf);
borra=(struct cliente *)pantalla (inbuf);

if (borra==(struct cliente *)NULL) return;
printf("\n Desea BORRAR esta ficha.. s/n ");

switch (toupper (getch()))
{
case 'N': return ;
case 'S': break;
}

if (borra==primero) primero = primero -> sigte;
else
{
indice = primero;
while (indice -> sigte !=borra)
indice= indice -> sigte;
indice -> sigte = borra -> sigte;
}

free (borra);
}

void guardar (void)
{

FILE *almacena ;
char inbuf [20];

system("cls");
printf("\nAlmacenar con nombre.dat: ");

while (kbhit());
gets (inbuf);
if ((almacena= fopen (inbuf, "wb"))==NULL)
{
perror ("\n NO puedo abrir el fichero de datos... ");
return;
}
indice=primero;


do
{
fwrite(indice, sizeof(struct cliente),1,almacena);
indice= indice ->sigte;
}while (indice != (struct cliente *)NULL);

fclose (almacena);

}


void recuperar(void)
{

FILE *lee;
char inbuf[20];

system("cls");
printf("\nLeer datos del archivo nombre.dat: ");

while (kbhit());
gets (inbuf);
if ((lee= fopen (inbuf, "rb"))==NULL)
{
perror("\n Error de acceso ");
return;
}
memo();

do
{
indice ->sigte = nuevo;
indice= nuevo;
fread (indice, sizeof(struct cliente), 1, lee);
nuevo= (struct cliente *) malloc (sizeof(struct cliente));
}while (indice-> sigte != NULL);
fclose (lee);

}


struct cliente *busca(char *inbuf)
{
indice = primero;

system("cls");
while (indice)
{
if (!strcmp(inbuf, indice -> nombre)) return indice;
indice = indice -> sigte;
}
puts("\n Dato no encontrado.... ");
return NULL;
}


struct cliente *pantalla (char *n_dato)
{
struct cliente *dato;

system("cls");
puts("\t Buscando dato... ");
if (!(dato = (struct cliente *) busca (n_dato)))
{
puts("\n Dato no encontrado..." );
return NULL;
}
else visualizar(dato);
return dato;

}

void memoria(void)
{
novo= (struct pelicula *) malloc (sizeof (struct pelicula));

if (novo == NULL)
{
printf ("\nEspacio insuficiente de memoria");
return;
}
if (uno == (struct pelicula *) NULL)
uno = indi = novo;
else
{
indi = uno;

while (indi -> siguiente!= (struct pelicula *)NULL)
indi = indi ->siguiente;
indi -> siguiente =novo;
indi =novo;
}
}


v

Última edición por keiko007; 16/07/2010 a las 09:52