I think I understand now, so thanks. I don't want to be a pain, but I've got another question. Why is:
Code:
while ((ch = getchar()) != '\n' && ch != EOF);
do {
printf("Ring elements? (yes/no) ");
ch=toupper(getchar());
switch(ch) {
case('Y'):
for (i=11; i<=15; i++) {
printf("Group %s: ", group_name[i]);
scanf("%i", &groups[i]);
}
break;
case('N'):
break;
default: printf("Incorrect choice, try again\n");
}
if (ch=='Y' || ch=='N') {
break;
}
} while (1);
working, and
Code:
do {
printf("Ring elements? (yes/no) ");
while ((ch = toupper(getchar())) != '\n' && ch != EOF);
switch(ch) {
case('Y'):
for (i=11; i<=15; i++) {
printf("Group %s: ", group_name[i]);
scanf("%i", &groups[i]);
}
break;
case('N'):
break;
default: printf("Incorrect choice, try again\n");
}
if (ch=='Y' || ch=='N') {
break;
}
} while (1);
isn't (ie still printing twice)?