- Código: Seleccionar todo
#include <stdlib.h>
#include <ctype.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void altas();
void muestra();
FILE *fich;
struct ficha{
int boleta;
char nombre [25];
char direccion [40];
char grupo[20];
} cliente;
void main()
{
textcolor(2);
char opcion;
if((fich=fopen("tele.txt","a+b"))==NULL)
{
printf("ERROR al crear fichero");
exit(0);
}
do
{
clrscr();
gotoxy(20,1);
textbackground(0);
gotoxy(24,2);
printf(" UNIVERSIDAD TECNOLOGICA DE NEZAHUALCOYOLT");
gotoxy(31,5);
printf(" DIVISION TELEMATICA");
gotoxy(30,10);
textcolor(22222222);
cprintf("CONTROL DE ALUMNOS");
textcolor(12);
gotoxy(34,15);
printf("ALTAS \n ");
gotoxy(34,16);
printf("CONSULTA \n");
gotoxy(34,17);
textcolor(2);
printf("SALIR \n\n");
textcolor(2);
gotoxy(10,32);
//cprintf("Para dar de alta a un alumno repita la operacion dos
veces");
gotoxy(30,20);
cprintf(" Elegir opcion:");
scanf("%c",&opcion);
fflush(stdin);
switch(toupper(opcion))
{
case 'A':
altas();
break;
case 'C':
muestra();
break;
}
}
while (toupper(opcion)!='S');
fclose(fich);
}
void altas()
{
clrscr();
printf("\t\t\t Escriba sus datos correctamente:\n\n");
printf("escriba su numero de boleta: \n");
scanf("%d",&cliente.boleta);
fflush(stdin);
printf("Nombre: ");
gets(cliente.nombre);
fflush(stdin);
printf("Direccion: ");
gets(cliente.direccion);
fflush(stdin);
printf("Grupo: ");
gets(cliente.grupo);
fflush(stdin);
fwrite(&cliente,sizeof(cliente),1,fich);
gotoxy(1,11);
printf("Seleccione la tecla enter para continuar:");
getch();
}
void muestra()
{
int cod_temp;
clrscr();
rewind(fich);
printf("\t\t\tBoleta a mostrar:");
scanf("%d",&cod_temp);
while (!feof(fich))
{
fread(&cliente,sizeof(cliente),1,fich);
if (cod_temp==cliente.boleta)
{
printf("\n\n Boleta:%d\n",cliente.boleta);
printf("\n Nombre:%s \n",cliente.nombre);
printf("\n Direccion:%s\n",cliente.direccion);
printf("\n\n Grupo:%s\n",cliente.grupo);
gotoxy(1,17);
printf("Selecione cualquier tecla para continuar");
getch();
break;
}
}
}
LA PREGUNTA ES:
ESTE PROGRAMA TIENE UN ERROR YA QUE SOLO VISUALIZA 5 REGISTROS COMO MAXIMO EN LA PARTE DE CONSULTA.
¿QUE MODIFICACION HARIAS PARA QUE EL PROGRAMA PUEDA CONSULTAR TODOS LOS REGISTROS QUE SE GENEREN?






