COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
string_find.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <string>
3using namespace std;
4
5int main()
6{
7 string s = "Outside it is cloudy and warm.";
8 string t = "cloudy";
9
10 cout << s.find("is") << endl;
11 cout << s.find('s') << endl;
12 cout << s.find(t) << endl;
13 cout << s.find('i', 6) << endl;
14 cout << s.find('o') << endl;
15 if (s.find ("the") == -1)
16 cout << "not found" << endl;
17 if (s.find ("the") == string::npos)
18 cout << "not found" << endl;
19
20 return 0;
21}
int main()