18 lines
435 B
C++
18 lines
435 B
C++
#include <iostream>
|
|
#include <string>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
string str1 = "My head is full of rocks, rocks I say!";
|
|
string str2 = "rock";
|
|
|
|
int pos = str1.find(str2);
|
|
cout << str1.substr(pos,str2.length()) << endl;
|
|
cout << str1.substr(pos,str2.length()+1) << endl;
|
|
cout << (str1.substr(pos,0) == "") << endl;
|
|
|
|
cout << str1.substr(pos,string::npos) << endl;
|
|
cout << int(string::npos) << endl;
|
|
|
|
return 0;
|
|
} |