我的家庭作业是读取一个文件,存储目标词(用# 分隔)和替换词(也用# 分隔)和原始字符串(它们没有#)。
我也不能假设最大 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
除了弄清楚如何使用带有替换字符串的目标字符串之外,我已经完成了一切。有可能做到strstr
吗?我知道它指向第一次出现,但是否可以让它指向字符串中的每一次出现?请告诉我使用伪代码。谢谢!