我需要将一个向量的元素复制到另一个向量中,但是在同一过程中,我需要能够从数据中删除注释或垃圾。例如; 其中两个要素是
(* Month: 2005 01 *) 31
(* Month: 2005 02 *) 29
我需要摆脱,(* Month: 2005 02 *)
然后将移到29
新向量中。我似乎无法弄清楚如何在c ++中执行此操作。
说
string str = "(* Month: 2005 01 *) 31";
你可以找到最后一个空间
size_t p = str.find_last_of(" ");
然后提取您感兴趣的子字符串
string sub_str = str.substr(p+1)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句