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
Post a Comment