gpt4 book ai didi

c - 头文件和函数,是我的函数、参数还是头原型(prototype)?

转载 作者:行者123 更新时间:2023-11-30 18:48:21 25 4
gpt4 key购买 nike

我刚刚开始使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com