Set field width
Sets a value to be used as the field width for the next insertion operation as if a call to stream member width(n).
The field width determines the minimum number of characters to be written by next insertion operation. If the standard width of the representation is shorter than the field width, the representation is padded with fill characters (setfill). You must include
Parameters.
- n
- Number of characters to be used as field width.
Unspecified.
This function should only be used as a stream manipulator.
Example.
// setw example
#include
#include
using namespace std;
int main () {
cout << setw (10);
cout << 77 << endl;
return 0;
}
This code uses setw to set the field width to 10 characters.
No comments:
Post a Comment