Home >Backend Development >C#.Net Tutorial >What does disp mean in c language
disp is the keyword for pointer to function in C language. Syntax: type (variable_name)(argument_list); where type is the pointer type, variable_name is the pointer variable, argument_list is the function parameter type and name list. Example: int (ptr_to_func)(int, int); ptr_to_func = add; (*ptr_to_func)(10, 20);
disp in C Meaning in the language
disp is a keyword in C language, used to define pointers to functions.
Use the disp keyword
The disp keyword is used to declare a function address. The syntax is as follows:
<code class="c">type (*variable_name)(argument_list);</code>
Among them:
type
is the type of the pointer to the function. variable_name
is the name of the pointer variable to the function. argument_list
is a list of types and names of function parameters. disp Keyword Example
The following example demonstrates the use of the disp keyword:
<code class="c">// 声明一个指向 int 型函数的指针 int (*ptr_to_func)(int, int); // 将 ptr_to_func 指向 add 函数 ptr_to_func = add; // 调用 add 函数通过 ptr_to_func 指针 int result = (*ptr_to_func)(10, 20);</code>
In this example, ptr_to_func
is a pointer to the add
function. add
The function type is int (*add)(int, int)
, which accepts two int parameters and returns an int value. ptr_to_func can be called like an ordinary function, and the pointed function is accessed through the dereference operator *
.
The above is the detailed content of What does disp mean in c language. For more information, please follow other related articles on the PHP Chinese website!