title: How can I determine if scanf read what was specified in format?
body: <p>I have a program that defines a variable <code>int data</code></p>
  
  <p>The program uses  <code>scanf("%d",&amp;data)</code> to read data from stdin.
  If the data from stdin is not an integer, I have to print error message.</p>
  
  <p>I tried <code>if(scanf("%d",&amp;data) ==EOF){ printf("error");return 1;}</code></p>
  
  <p>It didn`t works for me. So, how can I determine if scanf failed or succeeded?</p>