title: Returning local variables from function gives different output in two cases.
body: <pre><code>#include &lt;stdio.h&gt;
  char* fun1()
  {
    char *s="hello";
    return s;
  } 
  char* fun2()
  {
    char s[6]="hello";
    return s;
  }
  main()
  {
    char *str;
    str = fun1();
    printf("%s",str);//hello
    str = fun2();
    printf("%s",str);//garbage value
  }
  </code></pre>
  
  <p>The output of code is - hello and some garbage.
  I am not understanding that though both variables in fun1 and fun2 are local to their respective function,why output is coming like that.Both function calls are returning address of local variables and addresses returned should contain garbage value which is not true in fun1 case as it is printing "hello".</p>