home *** CD-ROM | disk | FTP | other *** search
- #pragma warning( disable:4786 )
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <ctime>
-
- using namespace std;
-
- void getDate( int &day,
- int &month,
- int &year )
- {
- time_t now = time(NULL);
- struct tm *pTm =
- localtime( &now );
- day = pTm->tm_mday;
- month = pTm->tm_mon;
- year = pTm->tm_year+1900;
- }
-
- string makeFileName()
- {
- int day, month, year;
- getDate(day,month,year);
-
- ostringstream os;
-
- os << day
- << "-"
- << month
- << "-"
- << year
- << ".log";
- return os.str();
- }
-
-
- void writeLog( const string &s )
- {
- string fname =
- makeFileName();
- ofstream of(
- fname.c_str(),
- ios::app );
- if (of.is_open())
- of << s << endl;
- }
-
-
- int main()
- {
- writeLog( "Something" );
- return 0;
- }