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