Split C string into tokens using sscanf

后端 未结 3 1505
既然无缘
既然无缘 2020-12-19 09:37

I\'m trying to split a string into tokens but somewhat recursively. I am trying to parse:

\"content=0&website=Google\"

so that I have a

3条回答
  •  Happy的楠姐
    2020-12-19 09:51

    Here is a solution that seems to work:

    char *contents = "content=0&website=Google";
    char arg[100] = {0};
    char value[100] = {0};
    sscanf(contents, "%[^&]&%s", arg, value);
    printf("%s\n%s\n", arg, value);
    

提交回复
热议问题