1. ## Error! Conflicting Types

Hi everyone! last night i got a headache just because of this error "Conflicting Types". I try to play around with my code in hope that it gonna fix the problem, but seem useless. Here is my program:
Code:
```/******************************************************************************/
/******** This program is combines from Project #2 thru #5 to find the *******/
/********** values that multiples of 7 or actually contain a digit 7 **********/
/******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#define MSIZE 500
#define DSIZE 500

int main()
{
int mul7[MSIZE];         //array multiples by 7
int dig7[DSIZE];         //array contain a digit 7
int n;                   //number
int sr;                  //starting range
int er;                  //engding range
int c7;                  //values that multiples by 7
int d7;                  //values that contain a digit 7
double mavg;             //average of values multiples by 7
double davg;             //average of values contain a digit 7

printf("Enter start and end range values: ");
while((n = scanf ("&#37;i %i", &sr, &er)) == 2)
{
if (sr < 0 || er > 999 || sr > er)
printf("Range value out of range\n");
else
{
c7 = fmul7(sr, er, mul7, MSIZE);
d7 = fdig7(sr, er, dig7, DSIZE);
mavg = calcavg(mul7, c7);
davg = calcavg(dig7, d7);
outresults(sr, er, mul7, MSIZE, dig7, DSIZE, c7, d7, mavg, davg);
printf("Enter start and end rage values: ");
}
}
if (n != EOF)
printf("Input error occurred in scanf\n");
system("PAUSE");
return 0;
}

/******************************************************************************/
/***** This little subprogram is about finding the values multiples by 7 ******/
/******************************************************************************/

int fmul7(int str, int endr, int mul7[], int m7size)
{
int ndx;         //index number
int rem;         //remain number
int i;           //count number

i = 0;
for (ndx = str; ndx <= endr; ndx++)
{
rem = ndx % 7;
if (rem == 0)
{
mul7[m7size] = ndx;
i = i + 1;
}
}

return 0;
}

/******************************************************************************/
/**** this little subprogram is about finding the values contain a digit 7 ****/
/******************************************************************************/

int fdig7(int str, int endr, int dig7[], int d7size)
{
int q1;          //first digit
int q2;          //second digit
int q3;          //third digit
int rem1;        //remainder
int num;         //number
int c7;          //count number

c7 = 0;

for(num = str; num <= endr; num++)
{
q1 = num / 100;
rem1 = num - (q1 * 100);
q2 = rem1 / 10;
q3 = rem1 - (q1 * 10);
if (q1 == 7 || q2 == 7 || q3 == 7)
{
dig7[d7size] = num;
c7++;
}
}

return 0;
}

/******************************************************************************/
/** This little subprogram is about finding the avarage of all number *********/
/******************************************************************************/

double calcavg(int md7[], int cntmd7)
{
int ndx;            //index number
int sum;            //total sum
double avg;         //total avarage

sum = 0;
avg = 0.0;

for (ndx = 0; ndx < cntmd7; ndx++)
sum = sum + md7[ndx];
if (cntmd7 == 0)
printf("Average divisor is zero - skip division \n");
else
avg = (double) sum / ndx;

return 0;
}

/******************************************************************************/
/************ This little subprogram is about output information **************/
/******************************************************************************/

void outresults (int sr, int er, int m7[], int szm7, int d7[], int szd7, int cm7,
int cd7, double mav, double dav)
{
int i;

printf("Start Range = %i    End Range = %i\n", sr, er);
printf("Multiple of 7 count is: %i\n", cm7);
printf("Number having digit 7 count is: %i\n", cd7);
printf("Multiple of 7 values are: \n");
for (i = 0; i < cm7; i++)
printf("%i\n", m7[i]);
printf("Values having digit 7 are: \n");
for (i = 0; i < cd7; i++)
printf("%i\n", d7[i]);
printf("Multiple of 7 average is: %0.2lf\n", mav);
printf("Values having digit 7 average is: %0.2lf\n", dav);
}```
I got error "coflicting types for 'calcavg', and conflicting types for 'outresults' "
i'm having a hard time doing subprogram. I have tried to look at the C tutorial in this home website, but seem like the tutorials didn't cover the subprogram! so, i'm really not sure if i did this program right or not! hope somebody can help me out!

2. What is the exact error message?

EDIT:
Right, the problem is that you failed to declare your functions before using them. Consequently, the implicit function declarations did not match with the function definitions (since arrays are not of the exact same type as pointers), hence the errors that you got.

3. I got error "coflicting types for 'calcavg', and conflicting types for 'outresults' "

4. Originally Posted by davewang
I got error "coflicting types for 'calcavg', and conflicting types for 'outresults' "
As I mentioned in my edit, you should declare your functions before using them (i.e., use function prototypes).

5. You need to include some function prologues at the top, then everything will be fine.

Code:
```double calcavg(int md7[], int cntmd7);
void outresults (int sr, int er, int m7[], int szm7, int d7[], int szd7, int cm7,
int cd7, double mav, double dav);```
I think the compiler is treating some reference prior to the actual definition as the prologue, so you get "conflicting types".

6. Error 2 error C3861: 'fmul7': identifier not found g:\w00t\visual studio 2008\projects\temp\temp4.cpp 30
Error 3 error C3861: 'fdig7': identifier not found g:\w00t\visual studio 2008\projects\temp\temp4.cpp 31
Error 4 error C3861: 'calcavg': identifier not found g:\w00t\visual studio 2008\projects\temp\temp4.cpp 32
Error 5 error C3861: 'calcavg': identifier not found g:\w00t\visual studio 2008\projects\temp\temp4.cpp 33
Error 6 error C3861: 'outresults': identifier not found g:\w00t\visual studio 2008\projects\temp\temp4.cpp 34

Your functions are missing prototypes as laserlight pointed out.

Originally Posted by MK27
You need to include some function prologues at the top, then everything will be fine.

Code:
```double calcavg(int md7[], int cntmd7);
void outresults (int sr, int er, int m7[], int szm7, int d7[], int szd7, int cm7,
int cd7, double mav, double dav);```
I think the compiler is treating some reference prior to the actual definition as the prologue, so you get "conflicting types".
The compiler treats all functions it cannot find prior to calls as
Code:
`int function();`
(Note the missing "void" on purpose.)

This silly behavior was removed in C99.