title: Why is %hd necessary in scanf?
body: <p>I created a very simple progam whith a menu,
  that take a value, then memorize it into the
  local variable value, and finally with the 
  second option the progam prints the value.</p>
  
  <p>my question is:
  Why does the program work only if I add an "h"
  to the scanf parameter?
  In other words: what kind of relation there is
  between scanf() and my local int value variable?</p>
  
  <p>thanks!</p>
  
  <p>p.S. (I used Dev-C++ (GCC) to compile it. 
  With Visual Studio it works)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  main () {
  
      int value = 0;
      short choice = 0;
  
      do {
         printf("\nYour Choice ---&gt; ");
         scanf("%d", &amp;choice);  /* replace with "%hd" and it works */
  
         switch (choice) {
            case 1:
                 printf("\nEnter a volue to store ");
                 scanf("%d", &amp;value);
                 getchar();              
                 printf("\nValue: %d", value);
                 break;
            case 2:
                 printf("\nValue: %d", value);            
                 break;  
         }
  
      } while (choice &lt; 3);
  
      getchar();
  }
  </code></pre>