jribble
asked on
Get text month given integer month
I know I can write a simple function to do this, but can show me an existing library function to return the text month (i.e., Jun or June) given the integer representation (1-12).
Thanks,
Joe
Thanks,
Joe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
using namespace std;
const char* Month[] = {"Months:","January","Febu
"May","June","July","Augus
"December"};
int main ()
{
cout << "Please enter a month (1-12):";
int GMonth;
cin >> GMonth;
cout << "The month you entered was, " << Month[GMonth] << endl;
return 0;
}
I know this isn't what you want, but I personally would just use an array like this. That way your program
relies on a lot less for doing this. For example, MrWad's example requires Time.h and Tchar.h and still
is based on 0-11 not 1-12. Is there a reason you want to use built-in libraries?