title: ending program using '\0' in c programming- while loop
body: <p>I have trouble finishing a while loop using <code>'\0'</code> in c programming language, the c code is the following</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  char r;
  
  int main()
  {
      do 
      {
          scanf("%c", &amp;r );
          printf("%c", r);
      }
      while (r!='\0');
  
      return 0;
  }
  </code></pre>
  
  <p>My problem is that the program never finishes at the final character of typed string line, the while loop is always in waiting mode because of the <code>scanf</code> and never go to <code>return 0</code>. I do not know why this happen.</p>
  
  <p>The output of this program is like this:</p>
  
  <pre><code>1234
  2345
  4556
  7788
  2345, 4556, 7788
  </code></pre>
  
  <p>Those are numbers I typed, but the program never finish (never go to <code>return 0</code>), I want to print just one string and I want the program ends.</p>