title: Write a program to divide the string into token and print it in C
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char *argv[]) {
      char token[20][256];
      char input[256];
      char *ctmp;
      int i = 1, cnt = 1;
      printf("$");
      scanf("%s", input);
      ctmp = strtok(input, " ");
      while (ctmp != NULL) {
          strcpy(token[cnt++], ctmp);
          ctmp = strtok(NULL, " ");
      }
      while (i &lt; cnt) {
          printf("%s\n", token[i]);
          i++;
          system("pause");
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I am trying to write a program which can divide " " from sentences into token.
  But it just work on 1st word but not a second word..</p>
  
  <p>Why it is so? am i doing something wrong?</p>