Thread: using * before array name

  1. #1
    Registered User
    Join Date
    Mar 2015
    Posts
    3

    using * before array name

    I see this code in a book
    Code:
    const char * MONTHS[12] ={ "January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December" };
    what does it mean (use * before MONTHS ) I know the meaning of
    Code:
    char( * MONTHS)[12]
    and why if I remve the * it throws the Error error C2078: too many initializers
    /

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    MONTHS is an array of 12 pointers to const char, not a pointer to an array of 12 char, as per your second example.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 07-31-2013, 12:15 AM
  2. Replies: 2
    Last Post: 03-20-2012, 08:41 AM
  3. Replies: 9
    Last Post: 08-23-2010, 02:31 PM
  4. Replies: 1
    Last Post: 10-21-2007, 07:44 AM
  5. Replies: 6
    Last Post: 11-09-2006, 03:28 AM

Tags for this Thread