title: Using scanf on integer
body: <p>My task is to create array, In order to do that I need to input size, but I have to make sure that the input isn't negative, letter or symbol. I created function to do that, but my if doesn't work properly. If I enter negative number or character it still uses it.</p>
  
  <p>Here's the function which I use:</p>
  
  <pre><code>void getsize(int* size){
      printf("Enter the size of array\n");
    if ((scanf("%d", size) == 1) &amp;&amp; (getchar() == '\n') &amp;&amp; (size &gt; 0)){
       printf("Size: %d entered\n", *size);
    } else {
     printf("wrong input\n");
     while(getchar() != '\n');
    }
  }
  
  getsize(&amp;size);
  </code></pre>