How to use adjustfield format flags width, internal, left and right in C++

1 Answer

0 votes
#include <iostream>
#include <iomanip> 

using std::cout;
using std::endl;

int main()
{
	int n = -131;

	cout.width(8); std::cout << std::internal << n << endl;
	cout.width(8); std::cout << std::left << n << endl;
	cout.width(8); std::cout << std::right << n << endl;

	return 0;
}


/*
run:

-    131
-131
    -131


*/

 



answered Apr 7, 2018 by avibootz
...