fork(1) download
  1. #include <stdio.h>
  2.  
  3. void parse(char *line, char **argv)
  4. {
  5. while (*line != '\0') { /* if not the end of line */
  6. while (*line == ' ' || *line == '\t' || *line == '\n')
  7. *line++ = '\0'; /* replace white spaces with 0 */
  8. *argv++ = line; /* save the argument position */
  9. while (*line != '\0' && *line != ' ' && *line != '\t' &&
  10. *line != '\n')
  11. line++; /* skip the argument until ... */
  12. }
  13. *argv = '\0'; /* mark the end of argument list */
  14. }
  15.  
  16. int main(void){
  17. char *p[8] = {0};
  18. int i;
  19. parse("1", p);
  20. for(i=0;i<8;++i){
  21. if(p[i] == NULL){
  22. printf("%d:NULL\n", i);
  23. break;
  24. }
  25. printf("%d:'%s'\n", i, p[i]);
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
0:'1'
1:NULL