繁体   English   中英

C错误:“类型冲突”

[英]C error: “conflicting types for”

我的程序包含以下代码:

static short index(key)
 unsigned char *key;
{
    long i, sum = 0;
    for (i = 0; key[i]; i++)
        sum += key[i];
    return(sum % TABLE_SIZE);
}

但是,它给出以下错误:

table.c:46:14: error: conflicting types for 'index'
 static short index(key)
              ^

我是C新手,了解有关原型设计的知识,但我无法解决问题。

indexC库中的函数。 如果您为函数选择其他名称,该错误将消失。

手册页中,我们看到它需要一个const char*和一个int

 #include <strings.h>

 char *index(const char *s, int c);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM