What is this mean!

This is a discussion on What is this mean! within the C Programming forums, part of the General Programming Boards category; I saw following statement in a C program. But I do not understand what exactly it means. Code: void (* ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    5

    Question What is this mean!

    I saw following statement in a C program. But I do not understand what exactly it means.

    Code:
    void (* const text[]) (void) = { &_one,two,three};
    It looks like a function but i see '=' and the pointer notation '*'; bit confused. Could anyone explain me what is that?
    This program is for an microcontroller (Anyway it does not matter I guess)

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,266
    It defines text as a array of const pointers to functions that accept no arguments and return void.

    The stuff after the equals sign initialises the array. _one, two, and three are presumably all functions that accept no arguments and return void. So text is an array of three function pointers.

    The const just means that the elements of the array cannot be changed after initialisation.
    Right 98% of the time, and don't care about the other 3%.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    5
    Hi Grumpy,

    Thanks for great explanation! I understood alomost everything except the syntax.

    I did little more research. Please look at this

    Code:
    int (*FunA[3])(float, char, char) = {one,two,three,four};
    This is a array for 4 function pointers.
    1. All these 4 function accept 3 values and their types are (float , char , char). Is it true?
    2. All these 4 functins will return int. That means "FunA" can not have pointer of a function that returns float. Is it true?
    3. If above two statements are true, What I understand is "arrary of function pointer is make sense when all functions are return same type and accepts same type". Is my understanding correct?


    One more unrelated question
    Waht is the difference of following two declaration
    int *i;
    int* i;

    Again Thanks for your time!

Popular pages Recent additions subscribe to a feed

Tags for this Thread


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