left-right.C |
#include <iostream.h> #include <iomanip.h> int main() { char s[] = "Katsurada"; cout.fill('#'); cout << "1. default" << endl; cout << setw(20) << s << endl; cout << "2. left" << endl; cout.width(20); cout.setf(ios::left, ios::adjustfield); cout << s << endl; cout << "3. internal" << endl; cout.width(20); cout.setf(ios::internal, ios::adjustfield); cout << s << endl; cout << "4. right" << endl; cout.width(20); cout.setf(ios::right, ios::adjustfield); cout << s << endl; cout << "5. left" << endl; cout << setw(20) << setiosflags(ios::left) << s << endl; cout << resetiosflags(ios::left); cout << "6. internal" << endl; cout << setw(20) << setiosflags(ios::internal) << s << endl; cout << resetiosflags(ios::internal); cout << "7. right" << endl; cout << setw(20) << setiosflags(ios::right) << s << endl; cout << endl << "internal は文字列に対しては意味がないみたい。" << endl; return 0; } |
left-right.out |
mathpc00% ./left-right 1. default ###########Katsurada 2. left Katsurada########### 3. internal ###########Katsurada 4. right ###########Katsurada 5. left Katsurada########### 6. internal ###########Katsurada 7. right ###########Katsurada internal は文字列に対しては意味がないみたい。 mathpc00% |