我刚刚开始使用 C,我的任务是使用 header 来容纳函数的原型(prototype)。问题是当我期待输入提示时什么也没有发生。我没有收到错误,想知道首先应该在哪里查看以解决我的问题。这就是我到目前为止所拥有的。
LAB2.c
#include <stdio.h>
#include "LAB2HEADER.h"
int main(){
double *p;
double array [10];
p = array;
const int size = 10;
void input(p,size);
return 0;
}
LAB2HEADER.h
#ifndef LAB2HEADER_H_
#define LAB2HEADER_H_
void input (double *array,const int size);
#endif
LAB2HEADER.c
#include <stdio.h>
#include "LAB2HEADER.h"
void input (double *array,const int size){
for (int i = 0; i < size ; i++)
{
printf("Input a value");
scanf("%lf", &array[i]);
}
}
我看的很多注释似乎只使用 Int 作为参数,或者有一个不需要参数的函数,我的错误可能是在我的数组指针中,是我制作函数的方式有问题吗?
最佳答案
void input(p,size);
这一行没有任何意义。如果这应该是函数调用,则需要删除 void
。
关于c - 头文件和函数,是我的函数、参数还是头原型(prototype)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46164921/