I am new to c and I am buliding a program with a buch of nested if and a switch statement based on my an input of a character from a scanf statement. the problem is when you ask the question what type it automatically defaults to illegal because I believe it is taken in the character alomg with a carriage return but I'm not sure. The following is what I have and according to the structure in the book it should work. If that is the problem how do I get around the carriage return.
Thanks
Code:
printf("What is the customer code?\n");
scanf("%c\n",&cc);
switch (cc) {
case 'R' :
case 'r' :
thresh = .0865;
excess = fee_r;
rate = r;
break;
case 'C' :
case 'c' :
thresh = .0695;
excess = fee_c;
rate = c;
break;
case 'I' :
case 'i' :
thresh = .0584;
excess = fee_i;
rate = i;
break;
default:
printf("Illegal customer code %c\n", cc);
}