This part seemed simple but I can't get it to work right. It is a DO WHILE loop until they press the s or h key. I use the getchar() to absorb any extra information left in the buffer from scanf().
If I change the != to == then it works to exit the loop if I press any key except those 2 so I know the OR logic operator is working.
I would rather not look at this for a whole year (1 hour to go until new years, joke).
-Lars
If I change the != to == then it works to exit the loop if I press any key except those 2 so I know the OR logic operator is working.
I would rather not look at this for a whole year (1 hour to go until new years, joke).
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char playerResponce;
printf("Press 'h' for 'Hit' or 's' for Stay:");
do{
scanf("%c", &playerResponce);
getchar();
printf("responce is: %c\n",playerResponce);
printf("Try again: ");
printf("\n");
} while(('h' != playerResponce) || ('s' != playerResponce));
printf("your out");
return 0;
}
-Lars