views:

198

answers:

4
+1  Q: 

c question

struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);

what is the meaning of this line?

what is the advantage of using

static struct hello
{
    int a;
    chat b;
};

over simply

struct hello
{
    int a;
};

also difference between static char p[]and char p[];

As i am very new to c programing language so help me friends. Regards lipune

+5  A: 

My C is a little rusty: requester is a constant pointer to a function returning a pointer to a ast_channel struct.

See these articles:

What the static keyword means is dependent on where the declaration appears in code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent when the function goes out of scope (i.e. is not running). Outside a function it indicates that the variable is not accessable outside the file it is in.

Mitch Wheat
+4  A: 

Teaching to fish (instead of giving the fish):

Reading C type declarations

What does static mean in a C program

Eli Bendersky
A: 

The first line is a function pointer, of the type ast_channnel. More of the code would need to be provided to adequately explain its use. Was that defined inside of a structure? If so, it would be entered via structname->requester( ... args ... ).

This tutorial might help you make sense of that. Links have already been provided by others to find out what 'static' implies.

Tim Post
+1  A: 

The first is a declaration (as well as definition) of a constant pointer to function which returns pointer to struct ast_channel and accepts parameters listed in the last pair of parantheses. This function pointer is named requester.

The meaning of static is actually dependent on the context. However it has been explained in previous answers.

dragonfly