c - Convert a comma separated string to an array in proc -


i need convert comma separated string array in proc, getting string in:

while ((ch = getopt(argc, argv, "do:c")) != eof) {     switch (ch)      {         case 'c':             get_order_type(optarg); 

get_order_type(optarg) comma separated string 30,31,32 need each string.

the function looking strtok. means string tokenizer.

i think work you:

  char str[] = get_order_type(optarg);    const char s[2] = ",";    char *token;     /* first token */    token = strtok(str, s);     /* walk through other tokens */    while( token != null )     {       printf( " %s\n", token );        token = strtok(null, s);    } 

anyway, here have documentation method.

hope helps!!


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -