本文介绍了在“-"上分割一个字符*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一种在符号->"上拆分char *的方法.
范例:abc-> efg
必须分为"abc"和"efg"
尝试使用strtok,但问题是它认为->"成为两个不同的符号,并在以下情况下引起问题:
abc-efg-> hyj
理想情况下,拆分应导致两个字符串"abc-efg"和"hyj"
strtok给出三个"abc","efg"和"hyj"
任何建议
I need a way to split a char * over the symbol "->"
Example : abc->efg
has to be split to "abc" and "efg"
tried using strtok but the problem is that it considers "->" to be two different symbols and cause problems in cases like :
abc-efg->hyj
ideally the split should result in two strings "abc-efg" and "hyj"
strtok gives three "abc" "efg" and "hyj"
Any suggestions
推荐答案
这篇关于在“-"上分割一个字符*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!