comment header (file i/o)
I feel pretty stupid for not being able to figure this out, but:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int hw_num;
int month;
int day;
ofstream file_out ("test.txt", ios::ate);
cout << "HW#: ";
cin >> hw_num;
cout << "Month: ";
cin >> month;
cout << "Day: ";
cin >> day;
file_out << "/* xxxxxxxxxxxxxxxxxx xxxxxxxxxxxx */\n";
file_out << "/* xxxxxxxxxxxxx xxxxxxxxxxxxxxxx */\n";
file_out << "/* HW#: " << hw_num << " Date: ";
file_out << month << "-" << day << "-03 */\n";
return 0;
}
I have only used file i/o to store settings in the past. I need this program to add information to the beginning of my sources for my homework, but it keeps writing over the whole file.
How do I get it to quit writing over the file?
And how do I make sure it adds the commenting to the beginning?
As always, thanks in advance.