COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
substring.cpp
Go to the documentation of this file.
1
#include <iostream>
2
#include <cstdio>
3
#include <string>
4
using namespace
std;
5
6
int
main
()
7
{
8
string
s;
9
string
str;
10
11
s =
"It is cloudy and warm."
;
12
13
cout <<
'\"'
<< s.substr(0, 5) <<
'\"'
<< endl;
14
cout <<
'\"'
<< s.substr(6, 6) <<
'\"'
<< endl;
15
cout <<
'\"'
<< s.substr(6, 16) <<
'\"'
<< endl;
16
cout <<
'\"'
<< s.substr(17, 10) <<
'\"'
<< endl;
17
cout <<
'\"'
<< s.substr(3, 6) <<
'\"'
<< endl;
18
str = s.substr(0, 8);
19
cout <<
'\"'
<< str <<
'\"'
<< endl;
20
str = s.substr(2, 10);
21
cout <<
'\"'
<< str <<
'\"'
<< endl;
22
23
24
return
0;
25
}
main
int main()
Definition
substring.cpp:6
Module6
Sample Code
Part III - C++ Strings
substring.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0