Hey all!
I don't mind poring for hours over code and trying to learn something by doing things in different ways but this is just PAINFUL. I cannot figure out why the default statement will not show up. If anyone could point me in the right direction, I would greatly appreciate it.
This is an extremely simplified version of my original code. The yes/no option worked at first after entering in A, B, or C, then the .exe suddenly started... ending itself. Or Windows did, rather. >_>
Code:
#include <stdio.h>
main()
{
char code, contexit, name;
do
{
printf("\nEnter name: ");
scanf("%s", &name);
do
{
printf("\nEnter code A/B/C: ");
scanf(" %c", &code);
}
while(code!='A' && code!='B' && code!='C');
switch (code)
{
case 'A':
printf("\nAAA: ");
break;
case 'B':
printf("\nBBB \n");
break;
case 'C':
printf("\nCCC \n");
break;
default:
printf("Please try again.");
break;
}
printf("\nYour name is: %s", name);
printf("\n\nContinue? Y/N\n");
scanf(" %c", &contexit);
}
while(contexit=='Y');
}
Thanks in advance!