title: Validate input of scanf
body: <p>I need to read hours:minutes in this exact format. I use:</p>
  
  <pre><code>    int hours, minutes;
  
      if (scanf("%d:%d", &amp;hours, &amp;minutes)!= 2)
      {
          printf("Wrong input.\n");
          return 1;
      }
  else if (minutes&gt;60 || minutes&lt;0 || hours&lt;0)
      {
          printf("Wrong input.\n");
          return 1;
      }
  
      time = hours*60 + minutes;
  
      /*read another time interval */
       if (scanf("%d:%d", &amp;hours, &amp;minutes)!= 2)
      {
          printf("Wrong input 2.\n");
          return 1;
      }
  else if (minutes&gt;60 || minutes&lt;0 || hours&lt;0)
      {
          printf("Wrong input 2.\n");
          return 1;
      }
     ...
  </code></pre>
  
  <p>works fine, but I need to get "wrong input" also in situations that someone enters e.g. 5:38abc </p>