J
Jess
Hello,
I'm trying to use setw and width functions to set the padding spaces
between numbers. The aim is to create two white spaces between two
double e.g. "1.1 1.2". I did:
streamsize s = cout.width(); // get the default width
cout << 1.1 << setw(2) << 1.2 << setw(s) << endl;
However, I didn't get any space at all, the output was simply
"1.11.2". Have I done something wrong?
Moreover, I had:
using std::width
but the compiler complained it and I had to remove "std". I thought
"width" is in std, is it not?
Thanks!
I'm trying to use setw and width functions to set the padding spaces
between numbers. The aim is to create two white spaces between two
double e.g. "1.1 1.2". I did:
streamsize s = cout.width(); // get the default width
cout << 1.1 << setw(2) << 1.2 << setw(s) << endl;
However, I didn't get any space at all, the output was simply
"1.11.2". Have I done something wrong?
Moreover, I had:
using std::width
but the compiler complained it and I had to remove "std". I thought
"width" is in std, is it not?
Thanks!