-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrtype2.cpp
More file actions
24 lines (22 loc) · 766 Bytes
/
strtype2.cpp
File metadata and controls
24 lines (22 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>
int main(int argc, char const *argv[]) {
using namespace std;
string s1 = "penguin";
string s2, s3;
std::cout << "You can assign one string object to annother: s2 = s1" << '\n';
s2 = s1;
std::cout << "s1 : " << s1 << ", s2 : " << s2 << '\n';
std::cout << "You can assign a C-style string to a string object" << '\n';
s2 = "buzzard";
std::cout << "s2 : " << s2 << '\n';
std::cout << "You can concatenate strings: s3 = s1 + s2" << '\n';
s3 = s1 + s2;
std::cout << "s3: " << s3 << '\n';
std::cout << "You can append strings" << '\n';
s1 += s2;
std::cout << "s1 += s2 yields s1 = " << s1 << '\n';
s2 += " for a day";
std::cout << "s2 += \" for a day \" yields s2 = " << s2 << '\n';
return 0;
}