string
This commit is contained in:
parent
48971c53ac
commit
de2f77b2b8
@ -78,4 +78,5 @@ add_executable(newexcp exception/newexcp.cpp)
|
||||
add_executable(use_sales exception/use_sales.cpp)
|
||||
add_executable(rtti1 exception/rtti1.cpp)
|
||||
add_executable(rtti2 exception/rtti2.cpp)
|
||||
add_executable(constcast exception/constcast.cpp)
|
||||
add_executable(constcast exception/constcast.cpp)
|
||||
add_executable(str1 string/str1.cpp)
|
35
base/string/str1.cpp
Normal file
35
base/string/str1.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by nicemoe on 2021/9/16.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include<string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
string one("Lottery Winner!");
|
||||
cout << one << endl;
|
||||
string two(20, '$');
|
||||
cout << two << endl;
|
||||
string three(one);
|
||||
cout << three << endl;
|
||||
one += " Oops!";
|
||||
cout << one << endl;
|
||||
two = "Sorry!That was ";
|
||||
three[0] = 'P';
|
||||
string four;
|
||||
four = two + three;
|
||||
cout << four << endl;
|
||||
char alls[] = "All's well that ends well";
|
||||
string five(alls, 20);
|
||||
cout << five << ", ";
|
||||
string six(alls + 6, alls + 10);
|
||||
cout << six << ", ";
|
||||
string seven(&five[6], &five[10]);
|
||||
cout << seven << "...\n";
|
||||
string eight(four, 7, 16);
|
||||
cout << eight << " in motion!" << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user