title: Store two integers from a String in C
body: <p>I am trying to write a program that prints two numbers from a string.</p>
  
  <p>For example, string = '20,66' I am trying to break this string apart so I can store '20' and '66' into two separate variables.</p>
  
  <p>Here is the code I am working on:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char line[80];
  
  int main(void)
  {
      // Variables
      int start_number, end_number;
      int i, j;
  
      while(1)
      {
          printf("Enter a number: ");
          fgets( line, sizeof(line), stdin);
  
          // How to find Comma
          for( i=0; i &lt; strlen(line); i++)
          {
              if(line[i]==',') break;
          }
  
          // How to find two numbers
          for(j = 0; j &lt; i; j++)
          {
              printf("1: %c\n", line[j]);         
          }
  
          for(j = i + 1; j &lt; strlen(line); j++)
          {
              printf("2: %c\n", line[j]);
          }
  
          if (strcmp(line, "quit\n") == 0)
          {
              printf("Now terminating program...");
              break;
          }       
  
      }   
  }
  </code></pre>
  
  <p>So far, I am only able to store single digit variables and for some reason prints an extra line.</p>
  
  <p>Any suggestions or advice will be appreciated. </p>