Split string with delimiters in C

前端 未结 20 1833
你的背包
你的背包 2020-11-21 11:56

How do I write a function to split and return an array for a string with delimiters in the C programming language?

char* str = \"JAN,FEB,MAR,APR,MAY,JUN,JUL,         


        
20条回答
  •  无人及你
    2020-11-21 12:14

    String tokenizer this code should put you in the right direction.

    int main(void) {
      char st[] ="Where there is will, there is a way.";
      char *ch;
      ch = strtok(st, " ");
      while (ch != NULL) {
      printf("%s\n", ch);
      ch = strtok(NULL, " ,");
      }
      getch();
      return 0;
    }
    

提交回复
热议问题