title: Unexpected behaviour, Garbage prints after string
body: <p>I was just trying to animate some strings before terminating the application. I called attached piece of code to do so. but it keeps on printing garbage till core dumped.</p>
  
  <p>Here is that code..</p>
  
  <pre><code>int terminate_msg(int quit_flag)
  {
      char server_msg[] = "\nApplication Not Alive";
      char exit_msg[] = "\nTerminating Application...\n";
      char *ch;
      int i = 0;
  
      if(quit_flag == 1) {
          printf("%s%s", server_msg, exit_msg);
          while((ch = server_msg + i) != NULL) {
              printf("%c",*ch);
              fflush(stdout);
              usleep(100000);
              i++;
          }
          i = 0;
          sleep(2);
          while((ch = exit_msg + i) != NULL) {
              printf("%c",*ch);
              fflush(stdout);
              usleep(100000);
              i++;
          }
          sleep(2);
      }   
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Application Not Alive
  Terminating Application...
  
  Application Not Alive
  Terminating Application...
  ���І�JS�dX��lX���p�dX��X��$���P
  l�UZ��D~�]P�up��IS�@q�P�q�M�dX��І@��!p�\X��^C
  </code></pre>
  
  <p>Though first <code>printf()</code> prints correctly, don't know why garbage prints are coming at the end. If there is any problem, garbage should come after first while loop also.</p>
  
  <p>Note that, when comparing <code>*ch != '\0'</code>, everything is working fine.</p>
  
  <p>What is wrong with this piece of code? I'm using <code>gcc</code> in linux environment.</p>