Foros del Web » Programación para mayores de 30 ;) » C/C++ »

[SOLUCIONADO] Ciclo While en funcion C

Estas en el tema de Ciclo While en funcion C en el foro de C/C++ en Foros del Web. Hola que tal a quien se encuentre leyendo esto, soy algo novato en esto de la programacion y estoy realizando un programa tipo control escolar ...
  #1 (permalink)  
Antiguo 07/12/2013, 02:04
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Exclamación Ciclo While en funcion C

Hola que tal a quien se encuentre leyendo esto, soy algo novato en esto de la programacion y estoy realizando un programa tipo control escolar pero tengo un pequeño problema en uno de los bucles while exactamente en la funcion Numero 4, consulta_calificacion por alguna razon pregunta primero si quiera otra consulta, sin haber terminado la primera vuelta, este es el codigo, exactamente la funcion inicia en la linea de codigo numero 164.

Código C:
Ver original
  1. int n=0,ultimo;
  2.  
  3.  struct alumno {
  4.         char nombre[100][20];
  5.         char matricula[100][20];
  6.         char domicilio[100][20];
  7.         char telefono[100][20];
  8.         char fecha[100][20];
  9.         char especialidad[100][20];
  10.         char grupo[100][20];
  11.         int  calif[100][20];
  12.        };
  13.        struct alumno uno;
  14.  
  15.  captura(){ _setcursortype ( _NORMALCURSOR );
  16.  char frank='o';
  17.  
  18.   gotoxy(6,4);printf("Matricula        : ");
  19.   gotoxy(6,6);printf("Nombre           : ");
  20.   gotoxy(6,8);printf("Domicilio        : ");
  21.  gotoxy(6,10);printf("Telefono         : ");
  22.  gotoxy(6,12);printf("Fecha de ingreso : ");
  23.  gotoxy(6,14);printf("Especialidad     : ");
  24.  gotoxy(6,16);printf("Grupo            : ");
  25.  
  26.  do{
  27.  n=n+1;
  28.  ultimo=n;
  29.  
  30.   gotoxy(25,4);clreol();
  31.   gotoxy(25,6);clreol();
  32.   gotoxy(25,8);clreol();
  33.  gotoxy(25,10);clreol();
  34.  gotoxy(25,12);clreol();
  35.  gotoxy(25,14);clreol();
  36.  gotoxy(25,16);clreol();
  37.  
  38.  gotoxy(25,4);gets(uno.matricula[n]);
  39.  gotoxy(25,6);gets(uno.nombre[n]);
  40.  gotoxy(25,8);gets(uno.domicilio[n]);
  41.  gotoxy(25,10);gets(uno.telefono[n]);
  42.  gotoxy(25,12);gets(uno.fecha[n]);
  43.  gotoxy(25,14);gets(uno.especialidad[n]);
  44.  gotoxy(25,16);gets(uno.grupo[n]);
  45.  
  46.  gotoxy(6,24);printf("[O] Registrar otro alumno,");
  47.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  48.  frank=getche();
  49.  gotoxy(6,24);clreol();
  50.  gotoxy(6,25);clreol();
  51.  }while(frank=='o' || frank=='O');
  52.   }
  53.  
  54.  actualizacion(){
  55.  char matri[20];
  56.  char frank='r';
  57.  int bandera=1;
  58.  int x;
  59.  
  60.  while(frank=='r' || frank=='R'){
  61.  gotoxy(4,3);printf("Matricula: ");
  62.  gets(matri);
  63.  
  64.  for(x=1; x<=ultimo; x++){
  65.  
  66.  bandera=strcmp(uno.matricula[x],matri);
  67.  
  68.  if(bandera==0){
  69.   gotoxy(6,4);printf("Matricula        : ");
  70.   gotoxy(6,6);printf("Nombre           : ");
  71.   gotoxy(6,8);printf("Domicilio        : ");
  72.  gotoxy(6,10);printf("Telefono         : ");
  73.  gotoxy(6,12);printf("Fecha de ingreso : ");
  74.  gotoxy(6,14);printf("Especialidad     : ");
  75.  gotoxy(6,16);printf("Grupo            : ");
  76.  
  77.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  78.  gotoxy(25,6);printf("%s",uno.nombre[x]);
  79.  gotoxy(25,8);printf("%s",uno.domicilio[x]);
  80.  gotoxy(25,10);printf("%s",uno.telefono[x]);
  81.  gotoxy(25,12);printf("%s",uno.fecha[x]);
  82.  gotoxy(25,14);printf("%s",uno.especialidad[x]);
  83.  gotoxy(25,16);printf("%s",uno.grupo[x]);
  84.  
  85.  gotoxy(25,4);gets(uno.matricula[x]);
  86.  gotoxy(25,6);gets(uno.nombre[x]);
  87.  gotoxy(25,8);gets(uno.domicilio[x]);
  88.  gotoxy(25,10);gets(uno.telefono[x]);
  89.  gotoxy(25,12);gets(uno.fecha[x]);
  90.  gotoxy(25,14);gets(uno.especialidad[x]);
  91.  gotoxy(25,16);gets(uno.grupo[x]);
  92.  
  93.  }
  94.  
  95.  }
  96.  gotoxy(6,24);printf("[R] Otra actualizacion");
  97.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  98.  frank=getche();
  99.  clrscr();
  100.  }
  101.  }
  102.  
  103.  registro_calificaciones(){
  104.  char matri[20];
  105.  int bandera=1;
  106.  int x;
  107.  char frank='o';
  108.  
  109.  while(frank=='o' || frank=='O'){
  110.  
  111.  gotoxy(4,3);printf("Matricula: ");
  112.  gets(matri);
  113.  gotoxy(4,3);clreol();
  114.  
  115.  for(x=1; x<=ultimo; x++){
  116.  bandera=strcmp(uno.matricula[x],matri);
  117.  
  118.  if(bandera==0){
  119.   gotoxy(6,4);printf("Matricula        : ");
  120.   gotoxy(6,5);printf("Nombre           : ");
  121.   gotoxy(6,6);printf("Especialidad     : ");
  122.   gotoxy(6,7);printf("Grupo            : ");
  123.  
  124.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  125.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  126.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  127.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  128.  
  129.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  130.   gotoxy(6,14);printf("Geometria Analitica : ");
  131.   gotoxy(6,16);printf("Estructura de Datos : ");
  132.   gotoxy(6,18);printf("HTML                : ");
  133.   gotoxy(6,20);printf("CTSyV II            : ");
  134.   gotoxy(6,22);printf("Biologia            : ");
  135.   gotoxy(6,24);printf("Ingles II           : ");
  136.  
  137.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  138.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  139.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  140.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  141.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  142.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  143.  
  144.   gotoxy(29,14);scanf("%i",&uno.calif[x][1]);
  145.   gotoxy(29,16);scanf("%i",&uno.calif[x][2]);
  146.   gotoxy(29,18);scanf("%i",&uno.calif[x][3]);
  147.   gotoxy(29,20);scanf("%i",&uno.calif[x][4]);
  148.   gotoxy(29,22);scanf("%i",&uno.calif[x][5]);
  149.   gotoxy(29,24);scanf("%i",&uno.calif[x][6]);
  150.  
  151.  }
  152.  
  153.  }
  154.  
  155.  
  156.  
  157.  gotoxy(6,27);printf("[O] Otro registro");
  158.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  159.  frank=getche();
  160.  clrscr();
  161.  }
  162.  }
  163.  
  164.  consulta_calificacion(){//ESTA ES LA FUNCION QUE ME GENERA EL PROBLEMA
  165.  char matri[20];
  166.  int bandera=1;
  167.  int x;
  168.  char bob='o';
  169.  
  170.  while(bob=='o' || bob=='O'){
  171.  
  172.  gotoxy(4,3);printf("Matricula: ");
  173.  gets(matri);
  174.  gotoxy(4,3);clreol();
  175.  
  176.  for(x=1; x<=ultimo; x++){
  177.  bandera=strcmp(uno.matricula[x],matri);
  178.  
  179.  if(bandera==0){
  180.   gotoxy(6,4);printf("Matricula        : ");
  181.   gotoxy(6,5);printf("Nombre           : ");
  182.   gotoxy(6,6);printf("Especialidad     : ");
  183.   gotoxy(6,7);printf("Grupo            : ");
  184.  
  185.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  186.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  187.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  188.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  189.  
  190.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  191.   gotoxy(6,14);printf("Geometria Analitica : ");
  192.   gotoxy(6,16);printf("Estructura de Datos : ");
  193.   gotoxy(6,18);printf("HTML                : ");
  194.   gotoxy(6,20);printf("CTSyV II            : ");
  195.   gotoxy(6,22);printf("Biologia            : ");
  196.   gotoxy(6,24);printf("Ingles II           : ");
  197.  
  198.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  199.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  200.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  201.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  202.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  203.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  204.  
  205.  }
  206.   }
  207.  gotoxy(6,27);printf("[O] Otra consulta");
  208.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  209.  bob=getche();
  210.  clrscr();
  211.  }
  212.   }
  213.  
  214.  impresion(){
  215.  
  216.  char nombre[20];
  217.  char matricula[20];
  218.  char domicilio[20];
  219.  char telefono[20];
  220.  char fecha[20];
  221.  char especialidad[20];
  222.  char grupo[20];
  223.  
  224.  int y, bandera1=0;
  225.  
  226.  textcolor(14);
  227.  gotoxy(2,3);cprintf(" Matricula        Nombre                           Telefono       Fecha Ingreso             Especialidad             Grupo");
  228.  for (int x=2; x<=124; x++){gotoxy(x,4);printf("="); }
  229.  
  230.  for(int y=1; y<=ultimo; y++){
  231.  gotoxy(3,6+y);printf("%s",uno.matricula[y]);
  232.  gotoxy(20,6+y);printf("%s",uno.nombre[y]);
  233.  gotoxy(53,6+y);printf("%s",uno.telefono[y]);
  234.  gotoxy(68,6+y);printf("%s",uno.fecha[y]);
  235.  gotoxy(94,6+y);printf("%s",uno.especialidad[y]);
  236.  gotoxy(120,6+y);printf("%s",uno.grupo[y]);
  237.  
  238.   }
  239.    }
  240.  
  241.  
  242.  main(){ _setcursortype ( _NOCURSOR );
  243.   char c;
  244.   char frank='s';
  245.  
  246.  while(frank=='s' || frank=='S'){
  247.  
  248.   textcolor(14);
  249.   gotoxy(12,4);cprintf("CONTROL ESCOLAR.");
  250.  
  251.    gotoxy(10,7);printf("1.- Alta de alumno.");
  252.    gotoxy(10,9);printf("2.- Mantenimiento.");
  253.   gotoxy(10,11);printf("3.- Registro de calificaciones.");
  254.   gotoxy(10,13);printf("4.- Consulta de calificaciones.");
  255.   gotoxy(10,15);printf("5.- Total de alumnos.");
  256.   gotoxy(10,17);printf("6.- Salir.");
  257.  
  258.   c=getche();
  259.    switch(c){
  260.  
  261.    case '1':
  262.    clrscr();
  263.    captura();
  264.    break;
  265.  
  266.    case '2':
  267.    clrscr();
  268.    actualizacion();
  269.    break;
  270.  
  271.    case '3':
  272.    clrscr();
  273.    registro_calificaciones();
  274.    break;
  275.  
  276.    case '4':
  277.    clrscr();
  278.    consulta_calificacion();
  279.    break;
  280.  
  281.    case '5':
  282.    clrscr();
  283.    impresion();
  284.    break;
  285.  
  286.    case '6':
  287.    clrscr();
  288.    return 0;
  289.    break;
  290.  
  291.    }//Cierre Switch - Case
  292.     gotoxy(6,24);printf("[S] Volver al menu");
  293.     gotoxy(6,25);printf("[TECLA CUALQUIERA] Salir.");
  294.     frank=getche();
  295.     clrscr();
  296.     }//cierre WHILE
  297.      }//Cierre MAIN

De antemano gracias, espero y puedan ayudarme a resolver mi problema, saludos.
  #2 (permalink)  
Antiguo 07/12/2013, 04:36
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

Bien veamos estas lineas :D

Aqui tenemos un bucle for de toda la vida no?
X empieza con 1...muy bien hasta aquí nada malo XD
Luego hacemos la comparación si x es menor o igual que ultimo x incrementa, nada nuevo aun peroooo ya sabemos que x ahora vale 2 ¿no?XDD
for(x=1; x<=ultimo; x++){
//bien miremos esta linea de aquí...
bandera le asignamos esto: strcmp(uno.matricula[x],matri);...que es un ¿que?...¿char?
Bandera es un int que inicia en 1...le metemos ahí un char ¿Y quieres ver si es igual a 0 en el siguiente bucle?
bandera=strcmp(uno.matricula[x],matri);

//para saber lo que vale bandera ahora mismo has un printf de bandera aquí bandera a ver lo que guarda y ya vas a saber por que te salta :D
Si bandera en este punto no es cero adiosssss XD
if(bandera==0){

no lo pruebo por que falta cachos de código.

En todo caso esto se puede o creo arreglar haciendo un contador if antes de
}
gotoxy(6,27);printf("[O] Otra consulta");
gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
bob=getche();
clrscr();
}
que empiece en 0 y al dar una vuelta en el while toma el valor de uno activando a la 2ª vuelta la pregunta.
Es una forma chapucera pero bueno XD
Suerte!

Última edición por vangodp; 07/12/2013 a las 04:44
  #3 (permalink)  
Antiguo 07/12/2013, 22:44
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Gracias, hice lo de el printf y me sale 49 O.o xD trate lo de el if y funciona para ingresar la matricula, pero sigue igual no termina el ciclo
  #4 (permalink)  
Antiguo 08/12/2013, 00:12
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

Por que no lo pones el código completo.
Le faltan cosas, si lo posta completo se puede echar un ojo ;)
  #5 (permalink)  
Antiguo 08/12/2013, 01:15
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Jejej en realidad esta completo solo faltan las librerias pero a continuacion lo cito, gracias de nuevo.

Código C:
Ver original
  1. #include <stdio.h>
  2.  #include <conio.h>
  3.  #include <string.h>
  4.  
  5.  int n=0,ultimo;
  6.  
  7.  struct alumno {
  8.         char nombre[100][20];
  9.         char matricula[100][20];
  10.         char domicilio[100][20];
  11.         char telefono[100][20];
  12.         char fecha[100][20];
  13.         char especialidad[100][20];
  14.         char grupo[100][20];
  15.         int  calif[100][20];
  16.        };
  17.        struct alumno uno;
  18.  
  19.  captura(){ _setcursortype ( _NORMALCURSOR );
  20.  char frank='o';
  21.  
  22.   gotoxy(6,4);printf("Matricula        : ");
  23.   gotoxy(6,6);printf("Nombre           : ");
  24.   gotoxy(6,8);printf("Domicilio        : ");
  25.  gotoxy(6,10);printf("Telefono         : ");
  26.  gotoxy(6,12);printf("Fecha de ingreso : ");
  27.  gotoxy(6,14);printf("Especialidad     : ");
  28.  gotoxy(6,16);printf("Grupo            : ");
  29.  
  30.  do{
  31.  n=n+1;
  32.  ultimo=n;
  33.  
  34.   gotoxy(25,4);clreol();
  35.   gotoxy(25,6);clreol();
  36.   gotoxy(25,8);clreol();
  37.  gotoxy(25,10);clreol();
  38.  gotoxy(25,12);clreol();
  39.  gotoxy(25,14);clreol();
  40.  gotoxy(25,16);clreol();
  41.  
  42.  gotoxy(25,4);gets(uno.matricula[n]);
  43.  gotoxy(25,6);gets(uno.nombre[n]);
  44.  gotoxy(25,8);gets(uno.domicilio[n]);
  45.  gotoxy(25,10);gets(uno.telefono[n]);
  46.  gotoxy(25,12);gets(uno.fecha[n]);
  47.  gotoxy(25,14);gets(uno.especialidad[n]);
  48.  gotoxy(25,16);gets(uno.grupo[n]);
  49.  
  50.  gotoxy(6,24);printf("[O] Registrar otro alumno,");
  51.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  52.  frank=getche();
  53.  gotoxy(6,24);clreol();
  54.  gotoxy(6,25);clreol();
  55.  }while(frank=='o' || frank=='O');
  56.   }
  57.  
  58.  actualizacion(){
  59.  char matri[20];
  60.  char frank='r';
  61.  int bandera=1;
  62.  int x;
  63.  
  64.  while(frank=='r' || frank=='R'){
  65.  gotoxy(4,3);printf("Matricula: ");
  66.  gets(matri);
  67.  
  68.  for(x=1; x<=ultimo; x++){
  69.  
  70.  bandera=strcmp(uno.matricula[x],matri);
  71.  
  72.  if(bandera==0){
  73.   gotoxy(6,4);printf("Matricula        : ");
  74.   gotoxy(6,6);printf("Nombre           : ");
  75.   gotoxy(6,8);printf("Domicilio        : ");
  76.  gotoxy(6,10);printf("Telefono         : ");
  77.  gotoxy(6,12);printf("Fecha de ingreso : ");
  78.  gotoxy(6,14);printf("Especialidad     : ");
  79.  gotoxy(6,16);printf("Grupo            : ");
  80.  
  81.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  82.  gotoxy(25,6);printf("%s",uno.nombre[x]);
  83.  gotoxy(25,8);printf("%s",uno.domicilio[x]);
  84.  gotoxy(25,10);printf("%s",uno.telefono[x]);
  85.  gotoxy(25,12);printf("%s",uno.fecha[x]);
  86.  gotoxy(25,14);printf("%s",uno.especialidad[x]);
  87.  gotoxy(25,16);printf("%s",uno.grupo[x]);
  88.  
  89.  gotoxy(25,4);gets(uno.matricula[x]);
  90.  gotoxy(25,6);gets(uno.nombre[x]);
  91.  gotoxy(25,8);gets(uno.domicilio[x]);
  92.  gotoxy(25,10);gets(uno.telefono[x]);
  93.  gotoxy(25,12);gets(uno.fecha[x]);
  94.  gotoxy(25,14);gets(uno.especialidad[x]);
  95.  gotoxy(25,16);gets(uno.grupo[x]);
  96.  
  97.  }
  98.  
  99.  }
  100.  gotoxy(6,24);printf("[R] Otra actualizacion");
  101.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  102.  frank=getche();
  103.  if(frank!='r' || frank!='R'){gotoxy(6,24);clreol();
  104.              gotoxy(6,25);clreol();}
  105.  if(frank=='r' || frank=='R'){clrscr();}
  106.  }
  107.  }
  108.  
  109.  registro_calificaciones(){
  110.  char matri[20];
  111.  int bandera=1;
  112.  int x;
  113.  char frank='o';
  114.  
  115.  while(frank=='o' || frank=='O'){
  116.  
  117.  gotoxy(4,3);printf("Matricula: ");
  118.  gets(matri);
  119.  gotoxy(4,3);clreol();
  120.  
  121.  for(x=1; x<=ultimo; x++){
  122.  bandera=strcmp(uno.matricula[x],matri);
  123.  
  124.  if(bandera==0){
  125.   gotoxy(6,4);printf("Matricula        : ");
  126.   gotoxy(6,5);printf("Nombre           : ");
  127.   gotoxy(6,6);printf("Especialidad     : ");
  128.   gotoxy(6,7);printf("Grupo            : ");
  129.  
  130.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  131.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  132.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  133.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  134.  
  135.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  136.   gotoxy(6,14);printf("Geometria Analitica : ");
  137.   gotoxy(6,16);printf("Estructura de Datos : ");
  138.   gotoxy(6,18);printf("HTML                : ");
  139.   gotoxy(6,20);printf("CTSyV II            : ");
  140.   gotoxy(6,22);printf("Biologia            : ");
  141.   gotoxy(6,24);printf("Ingles II           : ");
  142.  
  143.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  144.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  145.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  146.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  147.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  148.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  149.  
  150.   gotoxy(29,14);scanf("%i",&uno.calif[x][1]);
  151.   gotoxy(29,16);scanf("%i",&uno.calif[x][2]);
  152.   gotoxy(29,18);scanf("%i",&uno.calif[x][3]);
  153.   gotoxy(29,20);scanf("%i",&uno.calif[x][4]);
  154.   gotoxy(29,22);scanf("%i",&uno.calif[x][5]);
  155.   gotoxy(29,24);scanf("%i",&uno.calif[x][6]);
  156.  
  157.  }
  158.  
  159.  }
  160.  
  161.  
  162.  
  163.  gotoxy(6,27);printf("[O] Otro registro");
  164.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  165.  frank=getche();
  166.  clrscr();
  167.   if(frank!='o' || frank!='O'){gotoxy(6,27);clreol();
  168.              gotoxy(6,28);clreol();}
  169.  if(frank=='o' || frank=='O'){clrscr();}
  170.  }
  171.  }
  172.  
  173.  consulta_calificacion(){
  174.  char matri[20];
  175.  int bandera=1;
  176.  int x;
  177.  char bob='o';
  178.  
  179.  while(bob=='o' || bob=='O'){
  180.  gotoxy(4,3);printf("Matricula: ");
  181.  gets(matri);
  182.  gotoxy(4,3);clreol();
  183.  
  184.  for(x=1; x<=ultimo; x++){
  185.  bandera=strcmp(uno.matricula[x],matri);
  186.  
  187.  if(bandera==0 ){
  188.   gotoxy(6,4);printf("Matricula        : ");
  189.   gotoxy(6,5);printf("Nombre           : ");
  190.   gotoxy(6,6);printf("Especialidad     : ");
  191.   gotoxy(6,7);printf("Grupo            : ");
  192.  
  193.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  194.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  195.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  196.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  197.  
  198.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  199.   gotoxy(6,14);printf("Geometria Analitica : ");
  200.   gotoxy(6,16);printf("Estructura de Datos : ");
  201.   gotoxy(6,18);printf("HTML                : ");
  202.   gotoxy(6,20);printf("CTSyV II            : ");
  203.   gotoxy(6,22);printf("Biologia            : ");
  204.   gotoxy(6,24);printf("Ingles II           : ");
  205.  
  206.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  207.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  208.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  209.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  210.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  211.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  212.  
  213.  }
  214.   }
  215.  gotoxy(6,26);printf("%i",bandera);
  216.  gotoxy(6,27);printf("[O] Otra consulta");
  217.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  218.  bob=getche();
  219.  clrscr();
  220.  if(bob!='o' || bob!='O'){gotoxy(6,27);clreol();
  221.              gotoxy(6,28);clreol();}
  222.  if(bob=='o' || bob=='O'){clrscr();}
  223.  
  224.   }
  225.    }
  226.  
  227.  impresion(){
  228.  
  229.  char nombre[20];
  230.  char matricula[20];
  231.  char domicilio[20];
  232.  char telefono[20];
  233.  char fecha[20];
  234.  char especialidad[20];
  235.  char grupo[20];
  236.  
  237.  int y, bandera1=0;
  238.  
  239.  textcolor(14);
  240.  gotoxy(2,3);cprintf(" Matricula        Nombre                           Telefono       Fecha Ingreso             Especialidad             Grupo");
  241.  for (int x=2; x<=124; x++){gotoxy(x,4);printf("="); }
  242.  
  243.  for(int y=1; y<=ultimo; y++){
  244.  gotoxy(3,6+y);printf("%s",uno.matricula[y]);
  245.  gotoxy(20,6+y);printf("%s",uno.nombre[y]);
  246.  gotoxy(53,6+y);printf("%s",uno.telefono[y]);
  247.  gotoxy(68,6+y);printf("%s",uno.fecha[y]);
  248.  gotoxy(94,6+y);printf("%s",uno.especialidad[y]);
  249.  gotoxy(120,6+y);printf("%s",uno.grupo[y]);
  250.  
  251.   }
  252.    }
  253.  
  254.  
  255.  main(){ _setcursortype ( _NOCURSOR );
  256.   char c;
  257.   char frank='s';
  258.  
  259.  while(frank=='s' || frank=='S'){
  260.  
  261.   textcolor(14);
  262.   gotoxy(12,4);cprintf("CONTROL ESCOLAR.");
  263.  
  264.    gotoxy(10,7);printf("1.- Alta de alumno.");
  265.    gotoxy(10,9);printf("2.- Mantenimiento.");
  266.   gotoxy(10,11);printf("3.- Registro de calificaciones.");
  267.   gotoxy(10,13);printf("4.- Consulta de calificaciones.");
  268.   gotoxy(10,15);printf("5.- Total de alumnos.");
  269.   gotoxy(10,17);printf("6.- Salir.");
  270.  
  271.   c=getche();
  272.    switch(c){
  273.  
  274.    case '1':
  275.    clrscr();
  276.    captura();
  277.    break;
  278.  
  279.    case '2':
  280.    clrscr();
  281.    actualizacion();
  282.    break;
  283.  
  284.    case '3':
  285.    clrscr();
  286.    registro_calificaciones();
  287.    break;
  288.  
  289.    case '4':
  290.    clrscr();
  291.    consulta_calificacion();
  292.    break;
  293.  
  294.    case '5':
  295.    clrscr();
  296.    impresion();
  297.    break;
  298.  
  299.    case '6':
  300.    clrscr();
  301.    return 0;
  302.    break;
  303.  
  304.    }//Cierre Switch - Case
  305.     gotoxy(6,24);printf("[S] Volver al menu");
  306.     gotoxy(6,25);printf("[TECLA CUALQUIERA] Salir.");
  307.     frank=getche();
  308.     clrscr();
  309.     }//cierre WHILE
  310.      }//Cierre MAIN
  #6 (permalink)  
Antiguo 08/12/2013, 02:58
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

con que programa compilas??
Las funciones no pones el tipo de retorno?
Madre mía jaja me tira 500 errores XDD
A ver se supone que es c¿no?
De ser así que programa usas?
Por que no pones los tipos de retorno para las funciones ?
Esta linea que hace exactamente: _setcursortype ( _NORMALCURSOR ); ???
gotoxy dice que no esta declarada...¿por que sera?
  #7 (permalink)  
Antiguo 08/12/2013, 03:23
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Ah debe ser por eso lo compilo con Bordland c++

_setcursortype ( _NORMALCURSOR ); Es para aparecer o desaparecer el cursor en la consola
  #8 (permalink)  
Antiguo 08/12/2013, 03:29
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

Yo estoy con dev cpp

Creo que no tengo el conio.h por eso me da algunos errores
  #9 (permalink)  
Antiguo 08/12/2013, 03:46
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Cita:
Iniciado por vangodp Ver Mensaje
Yo estoy con dev cpp

Creo que no tengo el conio.h por eso me da algunos errores

Lamentable, de igual manera agraqdezco mucho tu interes por ayudarme, saludos y buenas noches.
  #10 (permalink)  
Antiguo 08/12/2013, 16:30
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

voy a ver como logro solucionar lo del conio.
A ver si encuentro la librería o a ver por que no la tengo.
Si no me equivoco conio es una librería de borland.
  #11 (permalink)  
Antiguo 08/12/2013, 16:49
 
Fecha de Ingreso: septiembre-2010
Mensajes: 494
Antigüedad: 13 años, 6 meses
Puntos: 10
Respuesta: Ciclo While en funcion C

Sin compilar el código, parece que no ha de haber problemas.
¿Por qué no añades una línea a la función que muestre el contenido de matri y de uno.matricula[x], porque se supone que el problema es que la función strcmp no encuentra equivalencias.
Algo como:
Código:
for(x=1; x<=ultimo; x++)
                {
               imprime matri;<----Aqui
               imprime uno.matricula[x];<--y aqui
                if(strcmp(uno.matricula[x],matri)==0)
                        {
                      ........................................
Por cierto, te puedes ahorrar la variable bandera si estableces como condición de if la propia comparación, como te dejo puesto en el extracto
  #12 (permalink)  
Antiguo 08/12/2013, 18:54
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Cita:
Iniciado por dehm Ver Mensaje
Sin compilar el código, parece que no ha de haber problemas.
¿Por qué no añades una línea a la función que muestre el contenido de matri y de uno.matricula[x], porque se supone que el problema es que la función strcmp no encuentra equivalencias.
Algo como:
Código:
for(x=1; x<=ultimo; x++)
                {
               imprime matri;<----Aqui
               imprime uno.matricula[x];<--y aqui
                if(strcmp(uno.matricula[x],matri)==0)
                        {
                      ........................................
Por cierto, te puedes ahorrar la variable bandera si estableces como condición de if la propia comparación, como te dejo puesto en el extracto
Buena observacion con lo de la variable bandera, gracias por tu ayuda
  #13 (permalink)  
Antiguo 08/12/2013, 21:37
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Genial muchas gracias a todos, por la ayuda al final eh conseguido resolver el problema, al parecer solo tuve que agregar la instruccion fflush(stdin); aqui el como funciona:

http://www.carlospes.com/curso_de_lenguaje_c/01_11_la_funcion_fflush.php
  #14 (permalink)  
Antiguo 09/12/2013, 03:37
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

buena info lo del fflush. jeje
Yo como lo programo en c++ pues algunos truquillos como este se me escapa XDD
como cin nunca me paso eso. XD
Estoy mirando todo lo referente a printf, scanf y similares, tienes mejor control que cout y cin pero la comodidad que te da esos no lo da ninguno. :D
  #15 (permalink)  
Antiguo 09/12/2013, 03:49
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Si tengo entendido que con cout y cin no es necesario poner que tipo de dato declararas "%s","%c" ,saludos! :D
  #16 (permalink)  
Antiguo 09/12/2013, 05:18
Avatar de vangodp  
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 6 meses
Puntos: 38
Respuesta: Ciclo While en funcion C

Exacto... pero con cout por ejemplo si pones el float, algo que sea ejemplo 00.10 solo te imprime 0.10 :/
Y muchas ma cosillas los %c, %s ... son muy buenos.
  #17 (permalink)  
Antiguo 09/12/2013, 13:45
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Cita:
Iniciado por vangodp Ver Mensaje
Exacto... pero con cout por ejemplo si pones el float, algo que sea ejemplo 00.10 solo te imprime 0.10 :/
Y muchas ma cosillas los %c, %s ... son muy buenos.
Si al final de cuentas solo son pequeños detalles, lastima que por undetalle por minusculo que sea te puedes pasar el dia tratando de hacer que corra el programa xD
como me paso xD, bueno gracias por tu ayuda vengodp saludos y que tengas un buen dia

Etiquetas: bucles, ciclos, condicional, funciones, infinito, repeticiones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:59.