Hi i am trying to understand manipulators. Can someone explain what is happening here
for (int i = 0; i < n; i++) {
cout << setiosflags(ios::left) << setw(15) << item[i]
<< setw(8) << setprecision(0) << code[i]
<< setiosflags(ios::right) << setw(8) << setprecision(2)
<< setiosflags(ios::fixed | ios::showpoint) << cost[i]
<< endl;
}
For the first time, i mean in the first iteration of the loop, it prints correctly but from the second iteration, the output always seems to be right justified. Why?
Here is the output of the above loop
dsjfh 102 32.32
jdshfjd 120 1212.00
dfdsfdsf 322 32.23