#include <iostream>
#include <chrono>
using namespace std;
void log(int result) {
cout << "then his age is " << result << endl;
if (result > 50) {
cout << "you are old";
} else if (result > 18) {
cout << "you are an adult";
} else {
cout << "you are still a child";
}
}
int main() {
auto date = chrono::system_clock::now();
auto year = format("{:%Y}", date);
int birth_year;
int current_year = stoi(year);
cout << "enter your year of birth: ";
cin >> birth_year;
int age = current_year - birth_year;
log(age);
return 0;
};
this is my code, i am using vscode gcc version 14.1.0
this error appeared:
‘format’ was not declared in this scope
i am new, i dont understand what does the error mean and i cannot find solution online
i changed the c++ standard on C/C++ Configurations to gnu++20 and the error message still appears.
New contributor
Carl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1