Small knowledge of function declaration and definition

#include <stdio.h>
void num(int a, int b);
//void num(int,int);//有效
//void num(int a=10,int b);//无效//因为默认实参不在形参列表结尾,就理解成实参不在形参定义时赋值。
//void num(int a=10,int b=20);//有效//但并不会改变传参的结果,意思是,传递到参数是不会重新定义,无论形参定义多少,只要实参不变,永远是20

int main(void)
{
    
    
	int a = 10, b = 10;
	num(a, b);
	return 0;
}
void num(int a, int b)
{
    
    
	printf("%d\n", a + b);
}
#include <stdio.h>
void num(int a, int b);
int main(void)
{
    
    
	int a = 10, b = 10;
	num(a, b);
	return 0;
}
void num(int c, int d)
{
    
    
	printf("%d\n", c+d);
}

And this kind of function declaration and definition can also run normally. After all, you don't even need the formal parameter name when you declare, only the number and type of parameters. To ensure that the scope of the parameters can not be grossly wrong.
If you have any questions, ask the boss for advice.
The code in all articles is compiled with VS2019.
thanks for reading.
I am a little white, all the text is to deepen my understanding.

Guess you like

Origin blog.csdn.net/weixin_52199109/article/details/111350468