0
我的家庭作业是读取文件,存储目标文字(用#分隔)和替换文字(也用#分隔)以及原始字符串(他们没有#)。如何找到多个发生并使用str替换?
此外,我不能假设最大字符串长度或最大字数。
例如:
#uic#e# // uic = target string e = replacement string
juice // find substring "uic" and replace it with 'e' resulting in "jee"
quicken // qeken
quiche // qehe
uicuicuick // eeek
#pp## // pp = target string nothing = replacement string
apples //ales
copper // coer
bopped //boed
#t#tttttt# // t = target string tttttt = replacement string
tut tut // ttttttutttttt ttttttutttttt
tttttttttttttttttttttttttttttttttttttttttttttttttttt // last string =
//# of t's * 6
我所做的一切,除了搞清楚如何使用目标字符串u /替换字符串。可以用strstr
做到吗?我知道它指向第一次出现,但是是否有可能使它指向字符串中的每一次出现?请使用伪代码显示我。谢谢!
“请使用伪代码显示我” - 不可以。你需要,并写一些代码... – 2013-02-14 04:23:23
告诉我们你的代码(刚刚看到你的编辑)。 – 2013-02-14 04:25:41
我不是要求转让。我在问是否有可能使用strstr指向另一个事件,并且是否有人可以为我显示伪代码。 – juice 2013-02-14 04:28:25