Problem with setw() and setfill('')

Hi, I'm new to C++ and can't figure this out.
I'm struggling with setw() and setfill(''),so I would like to know is there a possible way of applying this formating for every variable in line without writing macro that I made four times.

Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include <iostream>
#include <iomanip>
#define W14 setw(10)<<setfill('0')

using namespace std;

void main() {
	int a;
	long b;
	unsigned c;
	long unsigned d;

	cout << "Unesite promenljive...\n" << endl;
	cin >> a >> b >> c >> d;
	cout << dec << a << b << c << d << endl;

	system("pause");
}
Well the setfill() is sticky, meaning it stays in effect until it is changed again.

The setw() function must be called every time it is needed.

I strongly suggest that you avoid that ugly Macro and just stick with calling the required functions when required. IMO Macros should be avoided in C++ whenever possible.


Thanks for the advice.
Topic archived. No new replies allowed.