Home > Backend Development > C#.Net Tutorial > What are the methods of function calling in C language?

What are the methods of function calling in C language?

coldplay.xixi
Release: 2020-06-10 16:56:54
Original
11213 people have browsed it

What are the methods of function calling in C language?

#What are the methods of function calling in C language?

How to call functions in C language:

1. The most common is to call directly

void fun(void)
{
   ......
 //你的代码
   .....      
}
{
   .......
  fun();
    .....
 }
Copy after login

2.Use function pointer

void fun(void) 
{ 
    printf("OK!\n");
} 
int main(void) 
{ 
    void (*pfun)();    
    pfun=fun;
    (*pfun)();        
    return 0;
}
Copy after login

3. Function parameter method

void fun(void) 
{ 
    printf("OK!\n");
}  
{ 
    CallFun(fun);
Copy after login

In summary, there are three main methods of calling functions in C language: direct calling, function pointer calling, and function pointer passing calling. The latter two are essentially the same, but there are slight differences in whether there is a return value.

The above is the detailed content of What are the methods of function calling in C language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template