-
Notifications
You must be signed in to change notification settings - Fork 0
/
std_string.cpp
68 lines (53 loc) · 1.33 KB
/
std_string.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* =====================================================================================
*
* Filename: String.cpp
*
* Description:
*
* Version: 1.0
* Created: 2017年03月02日 16时25分04秒
* Last Modified: 2018-11-02 13:54:20
* Revision: none
* Compiler: gcc
*
* Author: zt (),
* Organization:
*
* =====================================================================================
*/
#include <iostream>
#include <fstream>
#include <string>
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main ( int argc, char* argv[] )
{
( void ) argc;
( void ) argv;
std::string str = "FILENAMEJKLMNOPQskkk";
std::size_t fd = str.find ( "Q" );
std::size_t rfd = str.rfind ( "Q" );
printf ( "fd=%ld rfd=%ld sz=%ld\n", fd, rfd, str.size() );
str.erase(fd);
std::cout<<str<<std::endl;
#if 0
//str.replace ( str.find ( "sssa" ), strlen ( "sssa" ), "kkk" );
for ( auto iter = str.rbegin(); iter != str.rend(); ++iter )
std::cout << *iter;
std::cout << std::endl;
for ( auto& ele : str )
std::cout << ele;
std::cout << std::endl;
std::ifstream file ( "a.txt", std::ios::in );
if ( file )
{
while ( !file.eof() )
str.push_back ( file.get() );
}
std::cout << str << std::endl;
#endif
return 0;
}