Home  >  Article  >  Backend Development  >  What are the methods of function calling in C language?

What are the methods of function calling in C language?

coldplay.xixi
coldplay.xixiOriginal
2020-06-10 16:56:5411115browse

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();
    .....
 }

2.Use function pointer

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

3. Function parameter method

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

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!

Statement:
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