Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:23:41+00:00 2026-06-15T19:23:41+00:00

I was wondering what would be better: An enumeration declaration or a string array:

  • 0

I was wondering what would be better:
An enumeration declaration or a string array:

enum MonthName{January, February, March, April, May, June, ...)

or

string MonthName[12] = {"January", "February", "March", "April", "May", "June", ...)

because to me it doesn’t seem like it matters.

This variable will only be accessed by one function, to display month based on the number input.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:23:42+00:00Added an answer on June 15, 2026 at 7:23 pm

    If you want to display the name of the month, an enum won’t do you any good at all. The identifiers in an enumeration type definition are visible only to the compiler; you can’t print them at run time.

    You need the array of strings (or perhaps an array of const char*s).

    The names of the months are also available via the standard library, using the strftime() function declared in <ctime> (from the C standard library’s <time.h> header). Getting the month name for a given month number using strftime() is not straightforward (you’d have to build a struct tm object first). It does have the advantage of using month names for the current locale rather than being hardwired to English.

    And don’t forget that array indices start at 0; December is at index 11, not 12.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just wondering would it be better to do this: if((fd = open(filename,
just wondering which approach would be better if both blocks of code would yield
I was wondering which type would have better performance and which you think should
I am writing some jsp and I am wondering if it would be better
Wondering what would be better for SEO and a spider, which is better for
I was wondering which way would be better if I were making a simple
I'm storing a simple tag relationship and I'm wondering what would be the better
I am just wondering whether it would be better to use PHP's Soundex Function
I was wondering would I still need to use a basic game loop for
I'm wondering what would be best to do. Right now I have running a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.