| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 691 人关注过本帖
标题:关于函数指针的高级应用~求C库函数源代码
只看楼主 加入收藏
摘星星的猴
Rank: 2
来 自:浙江
等 级:论坛游民
帖 子:14
专家分:23
注 册:2010-9-30
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
关于函数指针的高级应用~求C库函数源代码
这几天我在学习C语言的过程中学到了函数指针这一个概念。我通过查阅各种资料、以及自己举出的几个例子,勉强知道了几个函数指针使用的优点。但是函数指针具体的应用、该在什么时候使用函数指针等方面的概念都很模糊!

所以请教下谁能给个具体的关于函数指针使用的源代码了。

求C预言库函数源代码
搜索更多相关主题的帖子: 资料 C语言 源代码 概念 
2012-07-09 21:44
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:0 
搜索《C和C指针》及《C标准库》

我们都在路上。。。。。
2012-07-10 12:27
Rexfield
Rank: 6Rank: 6
来 自:幻想乡
等 级:侠之大者
威 望:1
帖 子:240
专家分:484
注 册:2010-7-28
收藏
得分:20 
程序代码:
typedef int (*Scanner)(void);
static Scanner        Scanners[256];
void SetupLexer(void)
{
    int i;

    for (i = 0; i < END_OF_FILE + 1; i++)
    {
        if (IsLetter(i))
        {
            Scanners[i] = ScanIdentifier;
        }
        else if (IsDigit(i))
        {
            Scanners[i] = ScanNumericLiteral;
        }
        else
        {
            Scanners[i] = ScanBadChar;
        }
    }

    Scanners[END_OF_FILE] = ScanEOF;
    Scanners['\''] = ScanCharLiteral;
    Scanners['"']  = ScanStringLiteral;
    Scanners['+']  = ScanPlus;
    Scanners['-']  = ScanMinus;
    Scanners['*']  = ScanStar;
    Scanners['/']  = ScanSlash;
    Scanners['%']  = ScanPercent;
    Scanners['<']  = ScanLess;
    Scanners['>']  = ScanGreat;
    Scanners['!']  = ScanExclamation;
    Scanners['=']  = ScanEqual;
    Scanners['|']  = ScanBar;
    Scanners['&']  = ScanAmpersand;
    Scanners['^']  = ScanCaret;
    Scanners['.']  = ScanDot;
    Scanners['{']  = ScanLBRACE;
    Scanners['}']  = ScanRBRACE;
    Scanners['[']  = ScanLBRACKET;
    Scanners[']']  = ScanRBRACKET;
    Scanners['(']  = ScanLPAREN;
    Scanners[')']  = ScanRPAREN;
    Scanners[',']  = ScanCOMMA;
    Scanners[';']  = ScanSEMICOLON;
    Scanners['~']  = ScanCOMP;
    Scanners['?']  = ScanQUESTION;
    Scanners[':']  = ScanCOLON;

    if (ExtraKeywords != NULL)
    {
        char *str;
        struct keyword *p;

        FOR_EACH_ITEM(char*, str, ExtraKeywords)
            p = keywords_;
            while (p->name)
            {
                if (strcmp(str, p->name) == 0)
                {
                    p->len = strlen(str);
                    break;
                }
                p++;
            }
        ENDFOR
    }
}

If you're not failing every now and again, it's a sign you're not doing anything very innovative.
2012-07-10 12:47
快速回复:关于函数指针的高级应用~求C库函数源代码
数据加载中...
 
   



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

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