c语言关于strtok函数应用问题

原本是想实现用strtok切割并输出各字串


#include

#include

 

    int main()

    {

        char str[] ="arcd,deewrg-98r|rewe,fhfe-rdd4|5h32";

        char *ch = strtok(str, ",-|");

        while(ch != NULL)

        {

            printf("%s\n", ch);

            ch = strtok(NULL, "-|,");

        }
        return 0;
    }

在vscode上运行这段代码提示一下界面,使用debug后又出现死循环,该怎么改正?

img


使用debug后死循环信息:

img

程序没问题,可以运行。只不过你没有关闭上次执行的窗口,把后台的的窗口都关掉,重新编译再运行