making file I/O modifiers persistent

I'm writing numeric data to several files. I'd like to set the formatting once, and have it remain in effect until changed. Unfortunately, when I do this:

1
2
3
4
5
6
	fileOutName = "data/demodagcout.txt";
	fileOut.setf(ios_base::hex, ios::basefield);
	fileOut.width(8);
	fileOut.fill('0');

	fileOut.open(fileOutName.c_str(), ios::ate);


The "hex" flag stays in effect, but it appears that the "width" and "fill" values only last for one output, then disappear. Is there a way to make them persistent?

Thanks.
Topic archived. No new replies allowed.