Using various format specifiers of c in c++

Viewed 23255

As in c we can use various format specifiers like

  • %nd where n is a number, to print the number with a total of atleast n space covered
  • %0nd same as above, except pre-padding with 0's " %05d ",3 => 00003
  • %.nf to set precision of n after decimal
  • etc ....

So is there any way to use these with std::cout ?

I got some negative feedback in a recent course (c++ for c programmers) in coursera, for using printf instead of cout because i wanted to some formatting :(

5 Answers
Related