Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 将两个结构数组作为参数传递给函数_C_Arrays_Function_Pointers_Struct - Fatal编程技术网

C 将两个结构数组作为参数传递给函数

C 将两个结构数组作为参数传递给函数,c,arrays,function,pointers,struct,C,Arrays,Function,Pointers,Struct,所以我有时间结构数组,它包含hh,mm,ss格式的时间。 我做了一个函数timeDifference,以秒为单位计算时间差 在函数中,如何将参数作为两个时间结构传递 我正在尝试这样做,并得到函数的隐式声明错误 int timeDifference(struct time T[i], struct time T[j]); T[i],T[j]可以参照两个时间结构T[0]和T[1],如下所示: struct time{ int hours; int minutes; int seconds; };

所以我有时间结构数组,它包含hh,mm,ss格式的时间。 我做了一个函数timeDifference,以秒为单位计算时间差

在函数中,如何将参数作为两个时间结构传递

我正在尝试这样做,并得到函数的隐式声明错误

int timeDifference(struct time T[i], struct time T[j]);
T[i],T[j]可以参照两个时间结构T[0]和T[1],如下所示:

struct time{
int hours;
int minutes;
int seconds;
};

int timeDifference(struct time T[i], struct time T[j]);

int main(){
struct time T[8]; // 9 time structures i.e 9 time values in hh,mm,ss
T[0].hours=2;
T[0].minutes= 00; // T[0]
T[0].seconds=00;

T[1].hours=3;
T[1].minutes=10;  // T[1]
T[1].seconds=00;

timeDifference(T[0], T[1]); Function call in main for evaluating difference

.
.
.
}

int timeDifference(struct time T[i], struct time T[j]) // function for 
                                                     // calculating difference
{
.
.
}
我认为它使用指针,我是C语言的新手,因此有人能推荐一些在线资源来理解指针吗?
谢谢

您正在使用一个编译器尚未看到声明的函数。 您需要在main之前声明函数,如下所示:

//rest of your code
int timeDifference(struct time T[], struct time T[]);
int main(){
//rest of your code
}

c有指针并不意味着你总是需要它们。在这里,您不需要。@EOF,函数不会接受这样的参数,获取错误和警告,隐式声明。
int-timeDifference(结构时间a,结构时间b)
。另外,请确保原型可用于
main()
。这也可以,但是我可以将数组索引作为参数传递吗@我已经做了,伙计,抱歉忘了展示;在开头的声明问题@k0staa