I want to accomplish task, that defines how many days is in specific Month, for this task i'm using date and time library to get current month, and then i want to check how many days in current month.
I'm getting this error:
no suitable constructor exists to convert from "char" to "std::basic_string, std::allocator>"
string daysInMonth(int month, string months);
time_t tt = system_clock::to_time_t(system_clock::now());
struct tm * ptm = localtime(&tt);
char buff[100];
int days;
string months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int month = ptm->tm_mon+1;
switch (month)
{
case May: {
days = 31;
cout << daysInMonth(month, months);
}
}
string daysInMonth(int month, string months) {
for (int i = 0; i < sizeof(months) / sizeof(months[0]); i++)
{
if (month == i)
{
return months[i - 1];
}
}
}