title: How to use sscanf with argv
body: <p>I want to get input from the command line, (n) but my code is only writing this progress bar. I can't figure out how to get it to print a statement like <code>Enter a value</code> and then take that value and run the program with it. I have tried putting it so many different places. Any suggestions? </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;time.h&gt;
  
  int main(int argc, char *argv[]) {
      //Check command line
      if (argc != 2) {
          printf("Usage: progress n\n");
          return 1;
      }
  
      int n = atoi(argv[1]);
      time_t c = atoi(argv[1]);
      int go = atoi(argv[1]);
  
      if (argc == 2) {
          //sscanf(argv[1], "%d", &amp;n);
          time(&amp;c);
          n = 10;
          go = n + c;
  
          char display[70];
          char equals[70];
          char disp[70];
  
          for (int i = 0; i &lt;= go * n; i++) {
              strcpy(display, "progress: |");
              strcat(equals, "=");
              strcpy(disp, "|");
  
              char number[70];
              char space[70];
  
              sscanf(argv[1], "%d", &amp;n);
              sprintf(number, "  %d%%", i * 2);
              sprintf(space, "%-52s", equals); // this keeps the 2nd bar static
              strcat(display, space);
  
              strcat(display, disp);
              strcat(display, number);
              //This is the final output
              fprintf(stderr, "\r%s %d  \r%s", equals, i, display);
  
              usleep(1000000);
          }
      }
      return 0;
  }
  </code></pre>