Ver Mensaje Individual
  #5 (permalink)  
Antiguo 20/05/2011, 08:46
Z3r9i0
 
Fecha de Ingreso: febrero-2006
Mensajes: 4
Antigüedad: 18 años, 2 meses
Puntos: 0
Respuesta: Salir de un While pulsando la tecla Escape

Buenas, buscando por la red encontre este codigo, a ver si te sirve.
Código C:
Ver original
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4.  
  5. #define ESCAPE_KEY 27
  6.  
  7.  
  8. int main(void)
  9. {
  10.    
  11.    int c;
  12.    
  13.    while ((c = getch()) != ESCAPE_KEY)
  14.    {
  15.       if (c == 0)
  16.       {
  17.          printf("0, ");
  18.          fflush(stdout);
  19.          c = getch();
  20.       }
  21.      
  22.       printf("%d\n", c);
  23.    }
  24.    
  25.    return EXIT_SUCCESS;
  26. }

me pregunto si esto se podra hacer usando cin y cout...

bueno saludos.