, x_flags long ios.
:
skipws -
left
right
dec
oct
hex
scientific
fixed
:
width
precision
fill
long a=1000, b=077;
cout.setf(ios::hex | ios::showbase | ios::uppercase);
cout.fill(.);
cout.width(10); cout<<a<<endl;
cout.width(10); cout<<b<<endl;
double d=0.12, c=1.3e-4;
cout.setf(ios::left);
cout.width(10); cout<<d<<endl;
cout.width(10); cout<<c:
, :
-
dec
oct
hex
ws
endl
ends
flush
-
setfill(int) -
setprecision(int)
setw(int)
:
enum io_state
{goodbit=0x00 //
eofbit=0x01 //
failbit=0x02 //
budbit=0x04 //
hardfail=0x08}; //
int rdstate()
int eof() , eofbit
int fail() , failbit, badbit hardfail
int bad() , badbit hardfail
int good() ,
operator void*() , 1
operator!() , 1
36) ++. - , .
:
ifstream -
ofstream -
fstream-
:
-
-
-
-
-
:
- ,
- ,
:
enum open_mode {
in =0x01 //
out =0x02 //
ate =0x04 //
app =0x08 //
trunc =0x10 // ,
nocreate =0x20 // ,
noreplace =0x40 // ,
binary =0x80}; //
|
|
- , :
- , -, , .
, .
37) ++. . .
string:
#include <iostream>
#include <string.h>
using namespace std;
void function()
{char s1[80], s2[80], s3[80];
strcpy(s1, old string); //
strcpy(s2, s1);
strcat(s3, s1); // ()
strcat(s3, s2);
if (strcmp(s2, s3)<0) cout<<s2; //
else cout<<s3;
}
void function2()
{string s1, s2, s3;
s1=new string; //
s2=s1;
s3=s1+s2; //
if (s2<s3) cout<<s2; //
else cout<<s3;
}
:
string()
string(const char *)
string(const char *, int n)
string(string&)
:
string& operator=(const string& str)
string& operator=(const char& s)
string& operator=(char c)
:
= >
+ >=
== [ ]
!= <<
< >>
<= +=
:
insert
erase
clear
replace
find
compare
size length
capacity
empty ,
, , .
: ( ) ( )
:
- (vector) , ,
- (deque) ,
- (list) ,
(stack), (queue), (priority_queue).
:
push_front -
pop_front
push_back
pop_back -
insert
erase
[], at
:
- (map)
- (multimap)
- (set)
- (multiset)
- (bitset)
, , - . - pair
value_type -
|
|
size_type - ,
iterator -
reverse_iterator -
reference -
:
key_type
:
iterator begin()
iterator end() ,
reverse_iterator rbegin()
reverse_iterator rend() , ,
:
size()
max_size()
empty() ,