Título: Estructura de datos Publicado por: juanks92 en 22 Abril 2013, 23:20 pm Tengo una duda ya me an estado corrigiendo ahora quiero saber por que todavia no me sigue compilando les agradeceria mucho
#include<conio.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #define max 5 struct alumno { char mat[10]; char nom[50]; char carrera[20]; int edad; }; int busqueda(alumno [10], char [20], int); void altas(struct alumno[10],int *); void bajas(struct alumno[10],int *); void cambios(struct alumno[10],int ); void consultas(struct alumno[10],int ); int main() { struct alumno students[10]; int contador=0; char opcion; do { system("cls") printf("1) Altas"); printf("2) Bajas"); printf("3) Cambios"); printf("4) Consultas"); printf("5) Salida"); printf("Opcion [ ]\b\b"); opcion=getch(); switch(opcion) { case '1': altas(students,&contador); break; case '2': bajas(students,&contador); break; case '3': cambios(students,contador); break; case '4': consultas(students,contador); break; case '5': break; default: printf("Opcion no valida"); getch(); } } while(opcion!='5'); int busqueda( struct alumno stu[], char llave[], int n) { int i; for (i=0; i<n; i++) if (strcmpi (stu.mat,llave)==0) return(i); return (-1); } void altas (struct alumno stu[], int *c) { int ban; char temp[10]; float aux; system("cls") if (*c <max) { do { clrscr(); printf("Matricula: "); fflush(stdin);// limpia el buffer de entrada de datos, sirve para cuando necesitas tomar muchos datos seguidos y se generan saltos de línea automáticos que se guardan en este buffer. gets(temp); ban=busqueda(stu,temp,*c); if (ban!=-1) { printf("Ya existe."); getch(); } } while (ban!=-1); strcpy(stu[*c].mat, temp); printf("Nombre: "); gets(stu[*c].nom); printf("Carrera: "); gets(stu[*c].carrera); printf("Edad: "); scanf("%d",&stu[*c].edad); } else { printf("No hay espacio suficiente"); getch(); } } void bajas (struct alumno stu[], int *c) { int pos,i; char temp[10]; system("cls") if (*c >0) { printf("Matricula: "); fflush(stdin); gets(temp); pos=busqueda(stu,temp,*c); if (pos!=-1) { for(i=pos;i<(*c)-1;i++) stu=stu[i+1]; (*c)--; } else { printf("No se encontro"); getch(); } } else { printf("No hay datos"); getch(); } } void consultas(struct alumno stu[], int c) { int pos,i; char temp[10]; system("cls") if (c >0) { printf("Matricula: "); system("cls") fflush(stdin); gets(temp); pos=busqueda(stu,temp,c); if (pos!=-1) { printf("\nMatricula: %s",stu[pos].mat); printf("\nNombre: %s", stu[pos].nom); printf("\nCarrera: %s", stu[pos].carrera); printf("\nEdad: %d", stu[pos].edad); getch(); } else { printf("No se encontro"); getch(); } } else { printf("No hay datos"); getch(); } } void cambios(struct alumno stu[], int c) { int pos; char temp[10],campo; float aux; system("cls") if (c >0) { printf("Matricula: "); fflush(stdin); gets(temp); pos=busqueda(stu,temp,c); if (pos!=-1) { do { system("cls") printf("--- Datos Actuales ---"); printf("Matricula: %s",stu[pos].mat); printf("\nNombre: %s", stu[pos].nom); printf("\nCarrera: %s", stu[pos].carrera); printf("\nEdad: %d", stu[pos].edad); printf("\n \n Seleccione el campo que desea cambiar \n" ); printf("1) Nombre"); printf("2) Carrera"); printf("3) Edad"); printf("4) Regresar al menu Principal"); printf("\nCampo: ");campo=getch(); fflush(stdin); switch(campo) { case '1': printf("Nombre: "); gets(stu[pos].nom); break; case '2': printf("Carrera: "); gets(stu[pos].carrera); break; case '3': printf("Edad: "); scanf("%d",&stu[pos].edad); break; break; case '4': break; } } while (campo!='4'); } else { printf("No se encontro"); getch(); } } else { printf("No hay datos"); getch(); } } } |