L
learning_C++
I hope to make a time class or a function. So I can make use it to
show time where I want. But it does not work.
Please help me!
Thanks,
class Time {
public:
string get_current_time();
};
string Time::get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
or I try to make a function like this:
string get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
it still does not work.
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
show time where I want. But it does not work.
Please help me!
Thanks,
class Time {
public:
string get_current_time();
};
string Time::get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
or I try to make a function like this:
string get_current_time(){
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}
it still does not work.
string timestr;
time_t rawtime;
struct tm * timeinfo;
time_t time ( &rawtime );
timeinfo = localtime ( &rawtime );
timestr=asctime(timeinfo);
}