0

So I have some code which looks like this

debug_file << left << setw(10) << timestamp << left 
<< setw(10) << activity_type << left << setw(10) << key << setw(10) 
<< left << event_data1 << setw(10) << left << event_data2 << setw(10) 
<< left << event_data2 << endl;

i would like to be able to write

// all output to debug_file defaults to left justify unless specified
// all output to debug_file defaults to setw(10)
debug_file << timestamp << activity_type << key << event_data1 << event_data2 
<< event_data3 << endl;

first of all, I'm not quite sure what this behaviour is called. Second, I don't know where in iomanip to look in order to do it. Now that I'm writing this I came up with the idea of making function which takes any input type and just does << left << setw(10) << input, but I'm still interested in if there's a pre-built solution.

AlexLordThorsen
  • 8,057
  • 5
  • 48
  • 103

1 Answers1

2

You can use the inbuilt function:

setiosflags()

Alok Save
  • 202,538
  • 53
  • 430
  • 533
  • Alright, that lead me to this page http://www.cplusplus.com/reference/ios/ios_base/fmtflags/ which I feel dumb for not finding earlier. Thanks. – AlexLordThorsen Dec 10 '12 at 06:44