看板 C_and_CPP 關於我們 聯絡資訊
網頁上的範例 string str1="There are two needles in this haystack with needles."; string str2="needle"; size_t found; found=str.find(str2); if(found!=string::npos) cout<<"first 'needle' found at: "<<int(found)<<endl; 到這邊我都還看的懂 found=str.find("needles are small",found+1,6) if(found!=string::npos) cout<<"second 'needle' found at: "<<int(found)<<endl; 這個我就看不懂了 他的 "needles are small",found+1,6 是哪裡來的... 三格的用處分別是什麼 謝謝指教 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.123.5
loveflames:found+1是從第一個needle的'e'開始找,6是"needle"長度 10/30 18:50
stupid0319:are small可以當作沒看到 10/30 18:54
funnymean:那我可以在" 裡面打隨便的東西都可以嗎?? 10/30 18:57