[問題] 字串的取代
開發平台(Platform): (Ex: VC++, Gcc, Linux, ...)
Dev_C++
問題(Question):
自檔案讀入文章放入char* buf 之後呼叫副程式replace(buf,pattern,target)
呼叫完buf後裡面的pattern全被取代成target
餵入的資料(Input):
自txt檔讀入文章 buf=abcdefg
預期的正確結果(Expected Output):
pattern=bcd;
targer=12345;
buf1=a12345efg;
補充說明(Supplement):
雖然老師是用char* 型態去宣告buf
小妹我想問說是否可以用string的函式達到效果
以及target長度大於pattern長度那文章裡面pattern之後的字不就都要移位?
會不會有空間不足問題呢?
最近小妹被string困擾...再麻煩大家幫幫忙解惑> <
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.228.251.133
→
12/19 02:03, , 1F
12/19 02:03, 1F
→
12/19 09:24, , 2F
12/19 09:24, 2F
推
12/19 09:53, , 3F
12/19 09:53, 3F
推
12/19 10:30, , 4F
12/19 10:30, 4F
→
12/19 10:49, , 5F
12/19 10:49, 5F
→
12/19 13:46, , 6F
12/19 13:46, 6F
→
12/19 13:47, , 7F
12/19 13:47, 7F
→
12/19 14:58, , 8F
12/19 14:58, 8F
→
12/19 14:59, , 9F
12/19 14:59, 9F
※ 編輯: haruhi6 來自: 114.26.16.153 (12/21 00:57)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章