Header files and functions, is my function, parameters, or header prototype?

1.2k views Asked by At

I just started with C and am tasked with using a header to house a prototype for a function. The problem is that nothing happens when I'm expecting a prompt for input. I didn't get an error and would like to know where to look at first to solve my problem. This is what I have so far.

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]);
}
}

A lot of the notes I look at seem to only either use Int as a parameter or have a function with no needed parameters, could my mistake be in my array pointer is it a problem with the way I made my function?

2

There are 2 answers

0
melpomene On BEST ANSWER
void input(p,size);

This line makes no sense. If this is supposed to be a function call, you need to remove void.

0
FredK On

Also, since your print statement does not end with a newline, nor do you flush stdout before reading in the value, your prompt might still be in the output buffer and not be output until you hit the newline AFTER entering the value.