标题:请教关于man函数的返回值问题
取消只看楼主
zhoujie13
Rank: 2
等 级:论坛游民
威 望:1
帖 子:29
专家分:38
注 册:2018-7-8
结帖率:66.67%
已结贴  问题点数:18 回复次数:1 
请教关于man函数的返回值问题
int main(int argc, char *argv[])
{
    char line[MAXLINE];
    long lineno = 0;
    int c, except = 0, number = 0, found = 0;

    while(--argc > 0 && (*++argv)[0] == '-')
        while(c = *++argv[0])
            switch (c)
            {
                case 'x':
                    except = 1;
                    break;
                case 'n':
                    number = 1;
                    break;
                default:
                    printf("find: illegal option %c\n", c);
                    argc = 0;
                    found = -1;
                    break;                  
            }
    if(argc != 1)
        printf("Usage: find -x -n pattern\n");
    else
        while(getlines(line, MAXLINE) > 0)
        {
            lineno++;
            if((strstr(line, *argv) != NULL) != except)
            {
               if(number)
                    printf("%ld:", lineno);
               printf("%s", line);
               found++;
            }
        }
    return found;
}
返回found有什么意义,不是很明白。改成返回0也能正常运行
搜索更多相关主题的帖子: 函数 line found while printf 
2018-08-02 13:06
zhoujie13
Rank: 2
等 级:论坛游民
威 望:1
帖 子:29
专家分:38
注 册:2018-7-8
得分:0 
回复 2楼 no1xijin
你说的我还是不明白
2018-08-02 14:41



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




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

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