Advertisement
Guest User

Untitled

a guest
Mar 26th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. int main()
  5. {
  6.     int color;
  7.  
  8.     do
  9.     {
  10.         printf("\nEnter mode --> ");
  11.         color = getchar();
  12.         if (color == 10)
  13.             continue;
  14.  
  15.         // clean buffer
  16.         int c;
  17.         while ((c = getchar()) != '\n' && c != EOF)
  18.         {
  19.         }
  20.  
  21.     } while (!isdigit(color) || (color != '1' && color != '0'));
  22.  
  23.     printf("\nCOLOR: %c\n", color);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement