setw
does not seem to be aligning things here for me, and I can't figure out why that is. Inserting \t
does push things to the right, but I'd like to have tighter control over the formatting of the output. Any ideas?
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main() {
string name = "Name LastName";
int age = 27;
double milesRun = 15.5;
ofstream outFile;
outFile.open("text.txt");
outFile << "Person's name: " << name << setw(12) << "Person's age: " << age << setw(12) << "Miles run: " << milesRun << endl;
outFile.close();
return 0;
}