I do not know any method to clear all flags, but you can use cout.unsetf( flags_here ) to remove some specific flags. The precision I donīt know, you could reset it to the default, I think that it is 5.
Hope that helps!
Flags:

Yep, that's right this is an ugly and stupid way to do things. Plus if foo() throws an exception you will never get cout to work right again. Although in this case there really is no good way to recover from the exception as we have already printed 'a' and a comma, so we're always going to be ugly. However for those who want a classy and safer way to do things boost comes to the rescue with io state savers While you are there you probably will want to go ahead and have a look at format