COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
string_find.cpp File Reference
#include <iostream>
#include <string>
Include dependency graph for string_find.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 5 of file string_find.cpp.

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}