the first time my program runs it gets the character from the keyboard
the second time it gets a 10 and I have not pressed any keys on the keyboard
#include <stdio.h>
#include <stdlib.h>
void showone();
void showtwo();
void showthree();
void showfour();
void showfive();
void showsix();
int randx();
char getans();
void blines();
int main(int argc, char **argv)
{
int r;
char ans;
ans = getans();
printf("%c\n",ans);
while(ans== 'y')
{
r = randx(6);
printf("%d\n",r);
printf("%c\n",ans);
blines(25);
if (r==1) showone();
if (r==2) showtwo();
if (r==3) showthree();
if (r==4) showfour();
if (r==5) showfive();
if (r==6) showsix();
blines(21);
ans = getans();
}
system("PAUSE");
}
void showone()
{
printf("\n * \n");
}
void showtwo()
{
printf(" * \n\n");
printf(" * \n");
}
void showthree()
{
printf(" * \n");
printf(" * \n");
printf(" *\n");
}
void showfour()
{
printf(" * * \n\n");
printf(" * * \n");
}
void showfive()
{
printf(" * * \n");
printf(" * \n");
printf(" * * \n");
}
void showsix()
{
int i;
for(i=1 ; i>=3 ; i++) printf(" * * \n");
}
void blines(int n)
{
int i;
for(i=1 ; i<=n ; i++) printf("\n");
}
char getans()
{
int ans;
printf("Throw y/n ?");
ans = -1;
while (ans == -1)
{
ans=getchar();
}
return ans;
}
int randx(int n)
{
return rand()%n + 1;
}