Bueno aqui estoy ya otra vez molestando >:D con el 4º tema sobre el mismo code, realmente me voy a alegrar cuando lo termine.El problema esta en al pulsar una tecla repetidamente deberia terminar el programa debido a la funcion kbhit(), pero no lo hace. :(
Code:
#include <ncurses.h>
#include <unistd.h>
int numbercookies=1;
char cookie[8];
bool bucle=true;
int kbhit(void)
{
int ch = getch();
if (ch != ERR) {
ungetch(ch);
return 1;
} else {
return 0;
}
}
void funcion(void)
{
while (bucle==true && 1)
{
initscr();
cbreak();
nodelay(stdscr,TRUE);
printw("I WANT A COOKIE\t");
numbercookies++;
refresh();
if (kbhit()){
numbercookies--;
}
else{
sleep(1);
}
sleep(1);
if (numbercookies==0) {bucle=false; }
}
endwin();
}
int main()
{
funcion();
return 0;
}
Espero que puedan ayudarme :D
Saludos ;D