-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrtype2.cpp
More file actions
26 lines (22 loc) · 819 Bytes
/
strtype2.cpp
File metadata and controls
26 lines (22 loc) · 819 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
25
26
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string s1 = "penguin";
string s2, s3;
cout << "You can assign one string object to anther: s2 = s1\n";
s2 = s1;
std::cout << "s1:" << s1 << "s2:" << s2 << std::endl;
std::cout << "You can assign a C-style string to a string object." << std::endl;
std::cout << "s2 = \"buzzard\"" << std::endl;
s2 = "buzzard";
std::cout << "s2:" << s2 << std::endl;
std::cout << "You can concatenate strings: s3 = s1 + s2" << std::endl;
s3 = s1 + s2;
std::cout << "s3:" << s3 << std::endl;
std::cout << "s1 += s2 yields s1 = " << s1 << std::endl;
s2 += "for a day";
std::cout << "s2 += \" for a day\" yields s2 = " << s2 << std::endl;
return 0;
}