0
#include "includes.h"

int main() {
   SYSTEMTIME st;
   GetSystemTime(&st);
   ofstream syslog;
   //st.wDay= 30
   syslog.open("today"st.wDay".txt");
   syslog.close();
system("Pause");
}

bt idk how to make it this line is completly wrong
syslog.open("today"st.wDay".txt");

can anyone help me :)

2
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Mr_PoP
0
#include <sstream>
#include <string>

std::string get_file_name(int sequence_number)
{
    std::stringstream out;

    out<<"today"<< sequence_number <<".txt";

    return out.str();
}

...

syslog.open(get_file_name(st.wDay));

Awkward, huh? :)

Edited by Narue: n/a

0
#include <sstream>
#include <string>

std::string get_file_name(int sequence_number)
{
    std::stringstream out;

    out<<"today"<< sequence_number <<".txt";

    return out.str();
}

...

syslog.open(get_file_name(st.wDay));

Awkward, huh? :)

Error 1 error C2601: 'get_file_name' : local function definitions are illegal

is there aonther way?

0

is there aonther way?

Yes, don't do it wrong. You clearly nested the get_file_name definition directly into main. Functions don't nest in C++.

0

Yes, don't do it wrong. You clearly nested the get_file_name definition directly into main. Functions don't nest in C++.

ya bt wat if i want to do it like this

"todat"<<" "<<st.wYear<<"-"<<st.wMonth<<"-"<<st.wDay<<".txt"

which will = to today 2010-12-30

0

ya bt wat if i want to do it like this

What about it? The changes to get that behavior are trivial.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.