title: format '%s' expects argument of type 'char *'
body: <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  int main(void)
  {
      int i,j,k;
      char st;
      printf("enter string\n");
      scanf("%s", st);
      printf("the entered string is %s\n", st);
  }
  </code></pre>
  
  <p>Compiling above program gives me a warning:</p>
  
  <pre class="lang-none prettyprint-override"><code>warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat]
  palindrom.c:8:1: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat]
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>This is what happens when I run it:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ ./a.out
  enter string
  kiaaa
  the entered string is (null)
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is another version of the code (made <code>char st;</code> into <code>char *st</code>):</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  int main(void)
  {
      int i,j,k;
      char *st;
      printf("enter string\n");
      scanf("%s", st);
      printf("the entered string is %s\n", st);
  }
  </code></pre>
  
  <p>However, it behaves the same on runtime.</p>