title: Storing inputs from stdin in an array in C
body: <p>I'm using the following code to store stdin into an array. I end up with a host of warnings and a segmentation fault.</p>
  
  <pre><code>while(fgets(str, 256, stdin)){
  
          size_t count = 0;
          char** arr = NULL;
          char* token = NULL;
          char* delim = ' ';
  
          for(int i=0; i &lt; strlen(str); i++) 
              if (isspace(str[i])) count++;
  
          count++;
          arr = malloc(sizeof(char*) * (count));
  
          for(int i=0; i &lt;= count; i++){
  
              token = strtok(str, delim);
              arr[i] = token;
          }
  
          for (int i = 0; i &lt; count; ++i)
          {
              printf("%s\n", arr[i]);
          }
  
          //if(strncasecmp(str, "quit", 4) == 0) break;
  
  
          free(arr);
  
      }
  </code></pre>
  
  <p>I'm a little confused about this warning in compilation </p>
  
  <pre><code>c:34:12: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'
        [-Wint-conversion]
          char* delim = ' ';
                ^       ~~~
  </code></pre>
  
  <p>And ofcourse finally when I run it I end up with a seg fault.</p>
  
  <pre><code>admin 123 tyu
  Segmentation fault: 11
  </code></pre>
  
  <p>What am I doing wrong here.</p>