Removing everything after character (and also character)

前端 未结 3 1943
星月不相逢
星月不相逢 2021-01-02 01:16

I have a string like this:

std::string string1 = \"xjdfhfakdjs%54k34k.-jk34\";

I need to get only \"\"xjdfhfakdjs\", but the string is dyna

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-02 02:05

    I believe that will work.

    std::string mystr = string1.substr(0, string1.find("%", 0));
    

提交回复
热议问题