Я просто хочу отформатировать строку и целочисленное значение с правильным выравниванием. Нет проблем сделать это без начального пробела перед целочисленным значением.
bytes.....................123981
total bytes..............1030131
Но это должно выглядеть так:
bytes ................... 123981
total bytes ............ 1030131
К сожалению, приведенный ниже пример не будет работать, потому что setw (выравнивание по правому краю) относится только к следующему элементу потока.
int iBytes = 123981;
int iTotalBytes = 1030131;
cout << setfill('.');
cout << right;
cout << "bytes " << setw(20) << " " << iBytes << endl;
cout << "total bytes " << setw(14) << " " << iTotalBytes << endl;
Я почти никогда не использую std::cout, поэтому есть ли простой способ сделать это без предварительного присоединения пробела к значению?