I define a function
我定义一个函数
int find(char *t, int len){
}
then i call it with
然后我用
value = "hello world";
rt = find(value, strlen(value));
it does not work, and show "error: too many arguments to function ‘find’"
它不起作用,并且显示了“错误:太多的参数不能用于‘查找’”
4 个解决方案
#1
2
int find(char *t, int len){
}
might give a warning that function should return a value.
可能会提示函数应该返回一个值。
and if you add:
如果你添加:
char* value = "hello world";
int rt = find(value, strlen(value));
It should work fine if the code is in a single file (as already pointed by Michael in comments) else you will have to specify the prototype of find
function before calling it from a separate file.
如果代码在一个文件中(如Michael在注释中指出的),那么它应该可以正常工作,否则您必须在从单独的文件调用之前指定find函数的原型。
#2
0
-
There is a syntax error in your call, no
;
aftervalue = "hello world"
您的调用有语法错误,没有;after value = "hello world"
-
Did you
#include <string.h>
?你# include < string.h >吗?
#3
0
This error might occur when there is difference in arguments between function declaration and function definition.
当函数声明和函数定义之间的参数不同时,可能会出现此错误。
#4
0
There are two errors that I found in the above code .
我在上面的代码中发现了两个错误。
You have to mention the 'return' keyword at the end of the function definition .
您必须在函数定义的末尾提到“return”关键字。
You have to declare the character pointer (char * value) while initialize the 'value' .
您必须在初始化“值”时声明字符指针(char * value)。
#1
2
int find(char *t, int len){
}
might give a warning that function should return a value.
可能会提示函数应该返回一个值。
and if you add:
如果你添加:
char* value = "hello world";
int rt = find(value, strlen(value));
It should work fine if the code is in a single file (as already pointed by Michael in comments) else you will have to specify the prototype of find
function before calling it from a separate file.
如果代码在一个文件中(如Michael在注释中指出的),那么它应该可以正常工作,否则您必须在从单独的文件调用之前指定find函数的原型。
#2
0
-
There is a syntax error in your call, no
;
aftervalue = "hello world"
您的调用有语法错误,没有;after value = "hello world"
-
Did you
#include <string.h>
?你# include < string.h >吗?
#3
0
This error might occur when there is difference in arguments between function declaration and function definition.
当函数声明和函数定义之间的参数不同时,可能会出现此错误。
#4
0
There are two errors that I found in the above code .
我在上面的代码中发现了两个错误。
You have to mention the 'return' keyword at the end of the function definition .
您必须在函数定义的末尾提到“return”关键字。
You have to declare the character pointer (char * value) while initialize the 'value' .
您必须在初始化“值”时声明字符指针(char * value)。