#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 :)

Recommended Answers

All 6 Replies

#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? :)

#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?

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++.

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

ya bt wat if i want to do it like this

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

thnx fixed :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.