XAgent-Smith

makeagument_arry

Oct 11th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. /*Author: XAgent Smith*/
  2. #ifndef strtok
  3.  
  4. #define TOK "string.h"
  5. #include TOK
  6. #endif
  7. #include<stdlib.h>
  8. int  makeargv(const char *s,const char *delemeter,char ***argvp)
  9. {
  10.     char *token;
  11.     int i=0;
  12.  
  13.     *argvp=(char**)malloc(sizeof(char)*strle(s)+8);
  14.  
  15.     char *ptr=(char*)malloc(sizeof(char)*strle(s)+8);
  16.  
  17.    copy(ptr, s);
  18.    token=strtok(ptr,delemeter);
  19.  
  20.    while(token!=NULL)
  21. {
  22.   *(*argvp+i++)=token;
  23.   token=strtok(NULL,delemeter);
  24. }
  25.  
  26. if(i<=0) return -1;
  27. return i;
  28.  
  29. }
  30. /***********************************/
Add Comment
Please, Sign In to add comment