c语言参数类型

今天看ntcip源码时看到,函数参数有点不一样。在函数实现时,没有括号中没有指明参数类型。注意这里说的是函数实现,不是说函数声明。这里在函数列表括号后面做了类型的说明,以前看到过,没想起来,今天做个记录。我在.cpp就是c++中试过,不行。这里os是windows,编译器是vc6.0

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 void show(int);
 4 
 5 int main(){
 6     int num_show = 1;
 7 
 8     show(num_show);
 9 
10     return 0;
11 }
12 
13 void show(num)                    //这里没有说明参数类型
14 int num;                        //这里说明了参数类型,注意后面有个分号
15 {
16     printf("num = %d
", num);
17 }

ps:这里是c语言,不是c++

另添加一小段,函数指针说明的代码,做个备忘

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 void show(int, void (* fun)());            //函数指针申明
 4 
 5 void test();
 6 
 7 int main(){
 8     int num_show = 1;
 9     
10     show(num_show, test);
11     return 0;
12 }
13 
14 void show(int num, void (* fun)())            
15 {
16     printf("num = %d
", num);
17     fun();                                //函数指针调用函数
18 }
19 
20 void test(){
21     printf("this is test func
");
22 }
原文地址:https://www.cnblogs.com/luckygxf/p/3982974.html