Small issue need help

I am trying to get a simple program to work but keep getting a LNK1561 error. What am i doing wrong here.

The main code
<
#include <iostream>
#include <fstream>
#include "average.h"



using namespace std;


int start()
{
cout << "this is to find the average of 5 numbers.";
cout << endl;
ifstream average;


cin.get();
cin.get();
return 0;
}
>

The header file
<
#include <cmath>


int avg( int average);
>

the cpp for the average
<
#include <iostream>
#include "average.h"
#include <cmath>

using namespace std;

int num[4];
int counter;
int sum;
int averages;

int avg(int average)

{

counter = 0;
while(counter <= 4);
{
cout << "enter a number ";
cin>> num[counter];
counter ++;
}

cout <<endl;



sum = 0;
for (counter = 0; counter < 4; counter ++)
sum = sum + num[counter];
averages = (sum / 5);
cout << "the average of your numbers was ";
cout << averages;
return (averages);

}
>
I could really use some help with this. Need an answer as soon as possible and it has to remain as separate files.
Last edited on
Can you print the error as the linker printed it please.
A linker error means the issue is not with the actual code but the files and method definitions. Post the full error and post average.h. Also, use click the <> to format your code with code tags.
1>------ Build started: Project: Goodman-files, Configuration: Debug Win32 ------
1>Build started 12/2/2012 9:20:26 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Goodman-files.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>LINK : fatal error LNK1561: entry point must be defined
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.19
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The errors

main code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#include <iostream>
#include <fstream>
#include "average.h"



using namespace std;


int start()
{
	cout << "this is to find the average of 5 numbers.";
	cout << endl;
	ifstream average;
	

	cin.get();
	cin.get();
	return 0;
}


header had to move most declarations to avg cpp to get to work.
1
2
3
4
5
#include <cmath>


int avg( int average);


avg cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include "average.h"
#include <cmath>

using namespace std;

int num[4];
int counter;
int sum;
int averages;

int avg(int average)
	
{	
	
	counter = 0;
	while(counter <= 4);
	{		
			cout << "enter a number ";	
			cin>> num[counter];			
			counter ++;
	}	
	
	cout <<endl;

	

	sum = 0;
		for (counter = 0; counter < 4; counter ++)
			sum = sum + num[counter];
			averages = (sum / 5);
		cout << "the average of your numbers was ";
		cout << averages;
		return (averages);

	}	
Topic archived. No new replies allowed.