Devaspora
10-14-2009, 05:21 PM
printf("question1? (y)es or (n)o?\n");
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
printf("Question2? (y)es or (n)o?");
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
printf("Question3? (y)es or (n)o?\n");
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
This is my code, and the problem is that only Question 1 doesnt allow you to input anything and automatically goes to default. Would anybody happen to know why this is?
Also this is so extra info:
int cats;
char o, w, a, g, h, c, x, y, n, xx[5],xxx;
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
printf("Question2? (y)es or (n)o?");
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
printf("Question3? (y)es or (n)o?\n");
gets(xx);
printf("\n");
switch (xx[0])
{
case 'y': printf("yes reply\n\n");
break;
case 'n': printf("no reply\n\n");
break;
default: printf("default\n\n");
}
This is my code, and the problem is that only Question 1 doesnt allow you to input anything and automatically goes to default. Would anybody happen to know why this is?
Also this is so extra info:
int cats;
char o, w, a, g, h, c, x, y, n, xx[5],xxx;