title: End of do-while loop in C language
body: <p>I'm new to the language C and here I have a code to add any number the user inputs using a do-while loop.</p>
  
  <p>For example if they type in 1, then 2, then 3, and finally 0, it should print out 6. So, my question is how to add these 3 numbers without ending the input with 0.</p>
  
  <p>I mean how can I let my code know that I have inputted all the numbers I have?</p>
  
  <p>For ex: </p>
  
  <pre><code>1
  2
  3
  output: 6
  
   or 
  
  10
  10
  10
  10
  output: 40
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  static char syscall_buf[256];
  #define syscall_read_int()          atoi(fgets(syscall_buf,256,stdin))
  
  main()
  {
      int input;
      int result = 0;
  
      do {
          input = syscall_read_int();
          result = result + input;
      } while(input != 0);
  
      printf("%i\n", result);
  }
  </code></pre>