标题:求助!很简单的指针应用,却提示错误!
取消只看楼主
clqngw
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-4-17
 问题点数:0 回复次数:1 
求助!很简单的指针应用,却提示错误!
函数指针作为函数参数的问题


#include<stdio.h>
int max(int a,int b)
{
    return a>b?a:b;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int getvalue(int (*p)(),int a,int b)
{
    return (*P)(a,b);
}
main()
{
    printf("The max of 3 and 4 is %d\n",getvalue(max,3,4));
    printf("The min of 3 and 4 is %d\n",getvalue(min,3,4));
}


再编译的时候提出警告
C:\Documents and Settings\Ever\桌面\c\函数指针作为函数的参数.c(12) : error C2064: term does not evaluate to a function
C:\Documents and Settings\Ever\桌面\c\函数指针作为函数的参数.c(12) : warning C4033: 'getvalue' must return a value
望高手指点   谢谢!呵呵
搜索更多相关主题的帖子: int 指针 函数 max min 
2008-05-21 10:49
clqngw
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-4-17
得分:0 
回复 2# 的帖子
多谢指点   呵呵   就是 因为大小写的失误致使函数没有返回值     谢谢!在这里也提醒初学者们一定要从开始学习就养成规范的好习惯!
2008-05-21 15:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-215389-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.579083 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved