   C++ right-justify loop output
  using for loop.want right-justification... can't figure out how setfill/setw would do this.any ideas?   
  Don't know why you want for-loop, but here is simple Windows solution:void Dummy(std::string const & rDummy){CONSOLE_SCREEN_BUFFER_INFO pDummy = {NULL};GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), & pDummy);std::cout << std::setw(pDummy.srWindow.Right + 1) << std::setfill('\x20') << rDummy << std::endl;}It will only look okay if rDummy is less or equal to console width of course.   ;  This should work on a win32 system:#include <iostream>#include <iomanip>using namespace std;#include <windows.h>int main(){    CONSOLE_SCREEN_BUFFER_INFO csbi;    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);    cout << setw(csbi.dwSize.X) << setiosflags(ios::right) << "hello" << endl;    return 0;};  I seem to remember having to do this in my programming class when I learned how to use formatting functions...ahhhh memories. Anyway, assuming you're printing a string, count the number of characters in the string to be printed, subtract that number from the value passed to setw, then pass that number into fill, then print the string.... should work....   