++ setiosflags () resetiosflags () , . . setiosflags() , resetiosflags() () . .
1
, | |
ios::skipws | |
ios::left | |
ios::right | |
ios::internal | |
ios::dec | |
ios::oct | |
ios::hex | |
ios::boolalpha | TRUE FALSE |
ios::showbase | |
ios::showpoint | |
ios::uppercase | |
ios::showpos | + |
ios::scientific | |
ios::fixed | |
ios::unitbuf | |
ios::sktdio |
, ios.
, :
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{ char s[]=" ";
cout << setw(30) << setiosflags(ios::right) << s << endl;
cout << setw(30) << setiosflags(ios::left) << s << endl;
}
:
setiosflags() resetiosflags(), , ios setf () unsetf (). :
#include <iostream>
using namespace std;
#include <string.h>
int main()
{ char *s=" ++";
cout.setf(ios::uppercase | ios::showbase | ios::hex);
cout << 88 << endl;
cout.unsetf(ios::uppercase);
cout << 88 << endl;
cout.unsetf(ios::uppercase | ios::showbase | ios::hex);
cout.setf(ios::dec);
int len = 10 + strlen(s);
cout.width(len);
cout << s << endl;
cout << 88 << " hello C++ " << 345.67 << endl;
return 0;
}
:
0X58
0x58
++
88 hello C++ 345.67