declaring a const...

This is a discussion on declaring a const... within the C Programming forums, part of the General Programming Boards category; I'm writing a program that draws a calendar for the month based on info taken from the system clock. In ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    9

    Question declaring a const...

    I'm writing a program that draws a calendar for the month based on info taken from the system clock. In the global declarations I have the following line which always gets a warning when compiled

    const int monthdays[12] = {"31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"};

    the warning I keep getting is
    'initializing' : 'const int ' differs in levels of indirection from 'char [3]'

    I don't understand why?!? isn't this just like declaring and initializing an array?

    can someone explain.

    Thanks

  2. #2
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284

    Re: declaring a const...

    Originally posted by insomniak
    I'm writing a program that draws a calendar for the month based on info taken from the system clock. In the global declarations I have the following line which always gets a warning when compiled

    const int monthdays[12] = {"31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"};

    the warning I keep getting is
    'initializing' : 'const int ' differs in levels of indirection from 'char [3]'

    I don't understand why?!? isn't this just like declaring and initializing an array?

    can someone explain.

    Thanks
    try
    Code:
    const int monthdays[12] = {31, 28,31, 30, 31, 30, 31, 31,30, 31, 30, 31};
    The one who says it cannot be done should never interrupt the one who is doing it.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    9
    OMG i cannot beleive how long I was looking at that. I should have caught that. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 04:34 PM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21