当前位置:网站首页>STL string input / output overload 1
STL string input / output overload 1
2022-07-19 11:50:00 【joker_ 0030】
1、string Function USES (string.app)
#include<iostream>
#include<cstring>//string class .
using namespace std;// Standard namespace .
int main()
{ // Create objects
string str;//NULL *m_str=NULL , new char('\n')
//const char* str1 = str.c_str();// new char('\n')
string str1(5, 'a');
cout << str1.c_str()<<endl;//size_type
string str2("abnc");
cout << str2.c_str() << endl;
string str3("abcdfeh", 3);
cout << str3.c_str() << endl;
string str4(str3,1,3);//[1,3) Subscript
cout << str4.c_str() << endl;
string str5(str3);//[1,3) Subscript
cout << str5.c_str() << endl;
cout << str2 << endl;
string str6("abcd");
cout << str6<<endl;
cin >> str6;
cout << str6 << endl;
system("pause");
return 0;
}
2、 Customize string function ( The main function Stringmain.app)
#include "Mystring.h"
int main()
{
stu str;
stu str1(5,'b');
cout << str1.c_str()<<endl;
stu str2("abcdef");
cout << str2.c_str() << endl;
stu str3("abcdefghehasdj",7);
cout << str3.c_str() << endl;
stu str4(str3,2,5);//[2,5)
cout << str4.c_str() << endl;
stu str5(str3);
cout << str5.c_str() << endl;
cout << str2<<endl;
stu str6("abd");
cout << str6 << endl;
cin >> str6 ;
cout << str6 << endl;
system("pause");
return 0;
}//( Header file and function implementation in string I / O overload 2 in )
边栏推荐
- Stc8h development (XIV): I2C drive rx8025t high-precision real-time clock chip
- [unity technology accumulation] realize the mouse line drawing function &linerenderer
- A simple websocket example
- Robot development -- common simulation software tools
- [multithreading] detailed explanation of JUC (callable interface, renntrantlock, semaphore, countdownlatch), thread safe set interview questions
- windows10:vscode下go语言的适配
- 数字化转型的两种误区
- 02-3、指针和引用的区别
- Tiflash performance tuning
- 02-3、指針和引用的區別
猜你喜欢

02-3、指针和引用的区别

LeetCode刷题——查找和最小的 K 对数字#373#Medium

jconsole线程面板中的阻塞总数和等待总数(转)

【无标题】cv 学习1转换

How to build dashboard and knowledge base in double chain note taking software? Take the embedded widget library notionpet as an example

02-3、指針和引用的區別

QT -- excellent open source project

mysql show processlist 详解

03-1. Inline function, auto keyword, typeID, nullptr

【嵌入式单元测试】C语言单元测试框架搭建
随机推荐
466-82(3、146、215)
动态内存分配问题
Leetcode 1252. 奇数值单元格的数目
STL string输入输出重载
【嵌入式单元测试】C语言单元测试框架搭建
【多线程】JUC详解 (Callable接口、RenntrantLock、Semaphore、CountDownLatch) 、线程安全集合类面试题
下推计算结果缓存
02-2. Default parameters, function overloading, reference, implicit type conversion, about error reporting
Docker install MySQL
Region 性能调优
02 - 3. Différences entre les pointeurs et les références
STM32F407 NVIC
【PostgreSQL 】PostgreSQL 15对distinct的优化
TiKV Follower Read
565. Array nesting: regular simulation questions
搭建OpenStack-M版的Cinder所碰到过的状况
Learning note 3 -- basic idea of machine learning in planning control
TCP congestion control details | 7 Surpass TCP
学习笔记3--规划控制中的机器学习基本思想
解决邮件客户端QQ Mail及Thunderbird无法登入Outlook的问题