I want to output data from my program to a text file. Here is a working example showing how I am doing this currently, where I also include the date / time (I am running Windows):
#include <iostream> #include <fstream> #include <time.h> using namespace std; int main() { char dateStr [9]; char timeStr [9]; _strdate(dateStr); _strtime(timeStr); ofstream output("info.txt", ios::out); output << "Start time part 1 " << "\t" << timeStr << " on " << dateStr << "\n"; output << "Start time part 1000000 " << "\t" << timeStr << " on " << dateStr << "\n"; output.close(); return 0; }
However, the output of "info.txt" is not very readable for me as a user, since the time and date stamp on the ends is not aligned. Here is the result:
Start time part 1 15:55:43 on 10/23/12 Start time part 1000000 15:55:43 on 10/23/12
My question is, is there a way to align the last part?
source share