I'm almost done this code, but I don't know why there is an error...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define FILENAME "chill.txt"
/* Define the structure */
struct windchill
{
int NROWS, NCOLS;
float NCOLStemp[17], NROWSspeed[21], matrix[21][17];
}
/* FUNCTION PARAMETERS */
float get_airTemp(float airTemp);
float get_windSpeed(float windSpeed);
float get_windChillTemp(struct windchill w1, int fileRow, int fileCol);
int main()
{
struct windchill w1;
int i, j, fileRow, fileCol, quit = 0;
int colCtr, rowCtr, matrixRowCtr, matrixColCtr;
float windChillTemp;
float airTemp, windSpeed;
/* Create a pointer of type file */
FILE *windChillFactorPtr;
w1.NROWS = 21;
w1.NCOLS = 17;
/* Open the file */
windChillFactorPtr = fopen(FILENAME, "r");
/* If file exists, run the program */
if(windChillFactorPtr != NULL)
{
printf("The file %s exists.\n", FILENAME);
while(quit != 1)
{
/* Run functions to get the wind speed and temperature */
get_airTemp(airTemp);
get_windSpeed(windSpeed);
/* Read values from air temperature into column array*/
for(j=0; j <= w1.NCOLS - 1; j++)
{
fscanf(windChillFactorPtr,"%f", &w1.NCOLStemp[j]);
}
/* Read values from wind speed into row array */
for(i=0; i<= w1.NROWS - 1; i++)
{
fscanf(windChillFactorPtr,"%f", &w1.NROWSspeed[i]);
}
/* Fill in the matrix */
for(i =0; i <= w1.NROWS -1; i++)
{
for(j =0; j <= w1.NCOLS -1; j++)
{
fscanf(windChillFactorPtr,"%f", &w1.matrix[i][j]);
}
}
/* Close the file */
fclose(windChillFactorPtr);
/* Call on function get_windChillTemp */
windChillTemp = get_windChillTemp(w1, fileRow, fileCol);
/* Print the final answer */
printf("Wind Chill Temperature = %f\n\n", windChillTemp);
/* To quit, have user enter 1 */
printf("Press any key to continue, 1 to quit.\n");
scanf("%d", &quit);
}
}
/* Otherwise, print an error message and quit the program. */
else
{
printf("Error occured when opening the file.");
}
system("PAUSE");
return 0;
}
/*-----------------------------------------------------*/
/* A function to get the air temperature from the user */
float get_airTemp(float airTemp)
{
printf("Enter the air temperature: \n");
scanf("%f", airTemp);
return airTemp;
}
/*-----------------------------------------------------*/
/* A function to get the wind speed from the user */
float get_windSpeed(float windSpeed)
{
printf("Enter the wind speed: \n");
scanf("%f", windSpeed);
return windSpeed;
}
float get_windChillTemp(struct windchill w1, int fileRow, int fileCol)
{
int k, l, finalK, finalL;
int airTemp, windSpeed;
float changeInTemp, windChillTemp;
w1.NROWS=21;
w1.NCOLS=17;
/* Get air temperature and wind speed from functions above */
airTemp = get_airTemp(airTemp);
windSpeed = get_windSpeed(windSpeed);
/* Round off air temperature and wind speed to a value in the file */
for(k=0; k <= w1.NCOLS; k++)
{
if(airTemp <= w1.NCOLStemp[k] && airTemp >= w1.NCOLStemp[k+1])
{
finalK = k;
}
}
for(l=0; l <= w1.NROWS; l++)
{
if(windSpeed >= w1.NROWSspeed[l] && windSpeed <= w1.NROWSspeed[l])
{
finalL = l;
}
}
/* List all possible options for rounding of numbers in the matrix */
if(abs(w1.NCOLStemp[finalK] - airTemp) < abs(w1.NCOLStemp[finalK+1] - airTemp) && abs(w1.NROWSspeed[finalL] - airTemp) < abs(w1.NROWSspeed[finalL+1] - airTemp))
{
changeInTemp = w1.matrix[finalK][finalL];
}
else if(abs(w1.NCOLStemp[finalK] - airTemp) > abs(w1.NCOLStemp[finalK+1] - airTemp) && abs(w1.NROWSspeed[finalL] - airTemp) < abs(w1.NROWSspeed[finalL+1] - airTemp))
{
changeInTemp = w1.matrix[finalK+1][finalL] ;
}
else if(abs(w1.NCOLStemp[finalK] - airTemp) < abs(w1.NCOLStemp[finalK+1] - airTemp) && abs(w1.NROWSspeed[finalL] - airTemp) > abs(w1.NROWSspeed[finalL+1] - airTemp))
{
changeInTemp = w1.matrix[finalK+1][finalL+1];
}
else
{
changeInTemp = w1.matrix[finalK][finalL+1];
}
/* To find wind chill temperature */
windChillTemp = airTemp - changeInTemp;
return windChillTemp;
system("PAUSE");
}
/*-----------------------------------------------------*/
The error is in line 15:
Code:
float get_airTemp(float airTemp);
It says: two or more data types in declaration of 'get_airTemp'
There is also an error without a line number, that says:
[Build Error] n\make.exe ***[Untitled1.o] Error 1
Does anyone know how to get rid of this?