Home > Back-end >  C language pointer complex definitions
C language pointer complex definitions

Time:03-23

Look not to understand the c language definition
Char * (* a [3]) (int * * p)
A is a pointer to the three elements of an array, each pointer to a prototype for the char * func (int * * p) as a function of
This function is not the same as the return type?
And the prototype char * func (int * * p) is a function pointer?
Char * func (int * * p) I understand it right? Func is a pointer to the return type is int the secondary, char * pointer to the function,

CodePudding user response:

Char * (* a [3]) * * p (int) is an array of three elements, the element type is char * func (int * *)
This is a function, the function of the return value is char * parameter is int * *

CodePudding user response:

 char * func (int * * p 

This is the function variables;

Can use a [0]=func. This assignment; Can also be a [0]=& amp; Func.

Call can use a [0] (p);
Examples are as follows:

 # include & lt; Stdio. H> 

* * a char * func (int);

Int main (void)
{
Int * * p=NULL;
Char * (* a [3]) (int * *);

//two spelled the same as
//a [0]=func.
A [0]=& amp; Func.

A [0] (p);

return 0;
}

Char * func (int * * a)
{
Printf (" % p \ n ", a);

Printf (" helloworld! \n");
Return NULL;
}


Because func function name is the name, address and do not add & amp; Can be,

CodePudding user response:

reference 1/f, the truth is right or wrong response:
char * (* a [3]) * * p (int) is an array of three elements, the element type is char * func (int * *)
This is a function, the function of the return value is char * parameter is int * *
meaning is inside three elements of the array is a function of the return type is char pointer of the parameters of the function is int the secondary pointer, right? The teacher

CodePudding user response:

reference 2 building self-confidence boy reply:
 char * func (int * * p 

This is the function variables;

Can use a [0]=func. This assignment; Can also be a [0]=& amp; Func.

Call can use a [0] (p);
Examples are as follows:

 # include & lt; Stdio. H> 

* * a char * func (int);

Int main (void)
{
Int * * p=NULL;
Char * (* a [3]) (int * *);

//two spelled the same as
//a [0]=func.
A [0]=& amp; Func.

A [0] (p);

return 0;
}

Char * func (int * * a)
{
Printf (" % p \ n ", a);

Printf (" helloworld! \n");
Return NULL;
}


Because func function name is the name, address and do not add & amp; Are allowed,
is not very good, char * func (int * * a) means the function parameter is int the secondary pointer, return a pointer to char types, right?

CodePudding user response:

 # include & lt; Stdio. H> 
Char * f1 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * f2 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * f3 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * (* a [3]) (int * * p) {f1, f2, f3};

Int main () {
A [0] (nullptr);
A [1] (nullptr);
A [2] (nullptr);

}

CodePudding user response:

If char * func (int * * p) this function accepts a secondary pointer type is an int and returns a value is the char type pointer, understand it right

CodePudding user response:

refer to fifth floor truth is right or wrong response:
 # include & lt; Stdio. H> 
Char * f1 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * f2 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * f3 (int * *) {
Printf (" % s ", __FUNCTION__);
Return nullptr.
}
Char * (* a [3]) (int * * p) {f1, f2, f3};

Int main () {
A [0] (nullptr);
A [1] (nullptr);
A [2] (nullptr);

}
teacher can not into empty parameters? To a slightly more complicated
  • Related