I’m new to C/C++, I’ve been using python, And I’m trying to get current time and partition it, But I’m having a problem acquiring the current time using ctime.
float t2lmst(){
QString t = ctime(time_t); //line with error
QString year =t.substr(20,4);
QString monthn =t.substr(4,3);
QString day =t.substr(8,2);
QString hour =t.substr(11,2);
QString minute =t.substr(14,2);
QString second =t.substr(17,2);
}
The error is exactly:
error: expected primary-expression before ')' token
You can’t pass a type to a function. You need to pass actual objects/structs.
ctimetakes a pointer to atime_t.Also
QStringdoesn’t have asubstrmember function. Look atmidand related functions instead. Or uselocaltime/gmtime. Or better yet, use the Qt date and time objects.