title: How to check if the user input an integer using scanf
body: <p>I created a program to make a diamond out of <code>*'s</code>. I am looking for a way to check if the type of input is an integer in the C language. If the input is not an integer I would like it to print a message. </p>
  
  <p>This is what I have thus far: </p>
  
  <pre><code>if(scanf("%i", &amp;n) != 1)
     printf("must enter integer");
  </code></pre>
  
  <p>However it does not display the message if it's not an integer. Any help/guidance with this issue would be greatly appreciated!</p>