ios_base& showpos (ios_base& str);
+) precedes every non-negative numerical value inserted into the stream (including zeros).<<) and extraction (>>) operations on streams (see example below).1
2
3
4
5
6
7
8
9
10
11
// modify showpos flag
#include <iostream> // std::cout, std::showpos, std::noshowpos
int main () {
int p = 1;
int z = 0;
int n = -1;
std::cout << std::showpos << p << '\t' << z << '\t' << n << '\n';
std::cout << std::noshowpos << p << '\t' << z << '\t' << n << '\n';
return 0;
}
+1 +0 -1 1 0 -1