Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //字串連續搜尋
- #include <iostream>
- #include <iostream>
- using namespace std;
- int main()
- {
- string s1="this is s1, and next is s2. we are strings.",s2="is";
- int target=s1.find(s2,0);
- int counter=0;
- while(target!=string::npos)
- {
- counter++;
- cout<<"found at "<<target<<endl;
- target=s1.find(s2,target+1);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment