zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    CString常用方法简介
    @PostConstruct与@PreDestroy
    Servlet知识
    Extjs ——radiogroup子元素宽度调整
    JS的Document属性和方法
    sql server
    C#中的结构,练习
    datagridview实现复制粘贴
    VS.NET2010水晶报表安装部署[VS2010]
    C#中基础知识积累
  • 原文地址:https://www.cnblogs.com/luckygxf/p/3982974.html
Copyright © 2011-2022 走看看