I closed out the other post I had "fill 2d array". The assignment is to read in a file to a 2d array that has the month #, high temp, low temp for each month. Then calculate the aver high and aver low and give the highest and lowest temps.
A fellow student helped me get on the right track for the problem of fillng the array.
I am breaking the pgm into pieces. I am trying to get the function working that finds the aver high. I am getting some errors that have me stumped. Any help would be appreciated.

>Chptr9_exer4.obj : error LNK2019: unresolved external symbol "double __cdecl AverHigh(double (* const)[3],int,double)" (?AverHigh@@YANQAY02NHN@Z) referenced in function _main
1>C:\Documents and Settings\User\Desktop\C++ Programming\Chapter 9\Chptr9_exer9\Debug\Chptr9_exer9.exe : fatal error LNK1120: 1 unresolved externals

Here is my code

#include <iostream> 
#include <fstream>
#include <iomanip>
using namespace std;
const int NUMBER_OF_ROWS = 12;
const int NUMBER_OF_COLUMNS = 3;

void GetData(ifstream& in, double m_t[][NUMBER_OF_COLUMNS], int NUMBER_OF_ROWS);
double AverHigh(double m_t[][NUMBER_OF_COLUMNS],int NUMBER_OF_ROWS, double aver_h);
int main()
	double m_t[12][3];
	double aver_h = 0;
//	double aver_l;
//	int high;
//	int low;
	ifstream in;
//	ofstream out;

	if (!in)
		cout << "Cannot open input file." << endl;
		return 1;
//	out.open("outdata");
	while (in)
		int row;
		int col;
		in >> row >> col;    // I'm trying to do a priming read

	    GetData(in, m_t, NUMBER_OF_ROWS);
		AverHigh(m_t, NUMBER_OF_ROWS, aver_h);
void GetData(ifstream& in, double m_t[][NUMBER_OF_COLUMNS], int numberOfRows)
	int row;
	int col;

	for (row=0; row < numberOfRows; row++)
		for (col=0; col < NUMBER_OF_COLUMNS; col++)
		in >> m_t[row][col];

double averHigh(double m_t[][NUMBER_OF_COLUMNS],int NUMBER_OF_ROWS, double aver_h)
   int c;
   int r;
//   double aver_h;
   for (c = 1; c < NUMBER_OF_COLUMNS; c++)
     double aver_h = 0;	 
     double sum = 0;
	  for (r = 0; r < NUMBER_OF_ROWS; r++)
		  sum = sum + m_t[r][c];
		  aver_h = sum / NUMBER_OF_ROWS;
  return aver_h;

Recommended Answers

All 3 Replies

Format your code better and the problem will smack you in the face...

I just responded to your other post (I had figured you had marked it as solved and changed your mind, I didn't know you had started a new one) with a concern about your aver_h in your AverHigh function.

Thanks to everyone for your help. Finally got it to compile and figured out what the problem was.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.