今年刚开始在我的大学学习 C,我很困惑我的函数调用是通过引用还是值。
我在 main 中创建了一个名为 freq_array 的空数组,并在调用函数频率时将其作为参数传递。那么既然在 func 调用之后,空数组现在将包含值,这被认为是按引用调用吗?我在其他通过引用调用的网站上读到使用指针,所以我有点困惑。谢谢你。
void frequency(int[]); //prototype
frequency(freq_array); //func call
void frequency(int fr[arraysize]) //arraysize = 18
{
int n;
for (n=0; n<10; n++)
{
fr[n]= 100 * (n + 1); //goes from 100Hz - 1000Hz
}
for (n=10; n<18; n++) //goes from 2000Hz - 9000Hz
{
fr[n]= 1000 * (n - 8);
}
}