Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Month Name

Status
Not open for further replies.

moonoo

Programmer
May 17, 2000
62
0
0
US
Hi ,
Is there a function in C++ to get the short month name
which takes the month Number .
Say I want to pass 03 and get "MAR" in return..
Any help will be appreciated ..
Regards
Dev
 
You could easily write your own code to do this:
Code:
#include <stdio.h>
#include <time.h>


int main (void)
{
  time_t tme;
  struct tm *today;

  char months[12][10] = { "January",
                          "February",
                          "March",
                          "April",
                          "May",
                          "June",
                          "July",
                          "August",
                          "September",
                          "November",
                          "December"
                        };

  time(&tme);
  today = localtime(&tme);
  printf("Current Month = %s\n", months[today->tm_mon]);

  return 0;  
}
But as far as your question goes, you could try using the function 'strtime()'.
:)

Don't hate the player - hate the game
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top