How can I make this program work.
I like to start to make a bit active programs, and starts in the small. I really like to hear from some of you, who knows something about this.
Tx
/* This program should be able to count up when the key u is pushed, and the same number should count down, if the key d is pushed..
*/
#include <stdio.h>
#include <conio.h>
#define U 100
#define D 117
int main()
{
int count = 0;
int ch;
printf("Her we count up or down..\n");
printf("Use the key 'u' to count up\n");
printf("Use the key 'd' to count down\n");
ch = getch();
switch(ch)
{
case U:
while(kbhit())
{
count++;
printf("%d", count);
if (ch == 'q')
return 0;
}
case D:
while(kbhit())
{
count--;
if (ch == 'q')
return 0;
}
default:
printf("Wrong key");
}
getch();
return 0;
}