SHARE
TWEET

Untitled

a guest Mar 26th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top