Thread: Pointer to 2D array?

  1. #1
    Registered User
    Join Date
    Oct 2008

    Question Pointer to 2D array?

    I am working on a project in C using libgnokii ( for reading sms from a cell phone, but I'm stuck with a problem that I think is C related rather than a problem with the library. The whole thing is more than a little confusing; I'll try to explain the best I can.

    The function used to access gnokii's capabilities is below

    gn_error gn_sm_functions(gn_operation op, gn_data *data, struct gn_statemachine *sm);
    The variable "data" is a struct holding pointers to all the
    different variables needed for any operation. Before an operation,
    it is up to the programmer to fill the pointers of the variables
    necessary to complete the operation.

    For example, to check the cell phone's battery level:

    float battery_level = 0;
    data.battery_level = &battery_level;
    error = gn_sm_functions(GN_OP_GetBatteryLevel, &data, state);
    I am having trouble with the specific struct member below.
    typedef struct{
        gn_sms_message_list *message_list[GN_SMS_MESSAGE_MAX_NUMBER][GN_SMS_FOLDER_MAX_NUMBER];
    Is this a pointer to a 2d array? I tried the following
        gn_sms_message_list    smsmessagelist[GN_SMS_MESSAGE_MAX_NUMBER][GN_SMS_FOLDER_MAX_NUMBER];
            data.message_list = &smsmessagelist;
        error = gn_sm_functions(GN_OP_GetSMS, &data, state);
    but the second line keeps giving me the error
    "error: incompatible types in assignment"

    Any Help is greatly appreciated.

    -Meredith M.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    It's not a pointer to a 2d array, it's a 2d array of pointers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D array pointer
    By taurus in forum C Programming
    Replies: 15
    Last Post: 10-30-2008, 12:30 PM
  2. Dynamic pointer array in C
    By MacFromOK in forum Windows Programming
    Replies: 14
    Last Post: 04-09-2005, 06:14 AM
  3. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM